As I am working on a project on my private SVN, there is a point where I want people to read the source and send pull requests. So, after some research, I have figured it out.
Let's assume the SVN is hosted at https://svn.inside-out.xyz/svn/my-project and that the GitHub repository is at https://github.com/user/my-project.
Many public GIT services won't allow username authentication, they need SSH authentication. For the specific case of GitHub you type:
If it is the first time, you will have to accept the server fingerprint, after that, you must have a successful message.
The GitHub project sometimes creates the master branch, but sometimes creates it under the name of main.
git branch --no-track svnsync git checkout svnsync git svn init -s https://svn.inside-out.xyz/svn/my-project git svn fetch --authors-file=/tmp/authors.txt git reset --hard remotes/origin/trunk
These commands will create a local branch that won't be managed by the git. It will switch to it and pull the content from your SVN.
The authors.txt file is optional, but it helps to keep track of changes. However, if you are using, you must map all users as it will fail if the fetch doesn't find one there. The content of the file is as follows:
One user per line.
At this point, the configurations are done. You are free to clone the SVN in another directory and use the svn add, svn ci, svn up commands as you want; you shouldn't be working on the SVN in the GIT directory, clone it somewhere else. The same applies to Git.
Note: if you break something during the process, you have to delete the branch in the GIT and restart again.
git checkout svnsync git svn rebase git checkout main git merge svnsync --allow-unrelated-histories git push origin main
The commands switch to the svnsync branch, they pull the changes, switch to the main branch, merge both branches into the main branch and push it to the git.
So, let's pretend you have accepted some pull requests and you need to sync your SVN now. Follow these commands:
git checkout main git pull origin main git checkout svnsync git svn rebase git merge --no-ff main git commit git svn dcommit
What happens is: you switch to the main branch, pull the changes, switch to the svncyn branch, pull the changes, merge the main into the svnsync, commit into the local branch and then commit to the SVN. Please note that commit must be done before dcommit.
Good luck!blog comments powered by Disqus