how to use Git to access a SVN repo - specific case
I think that's a really specific case where people don't need to get access to my featured Git branches.
Other developers are used to use only the /trunk in SVN. They only track changes made into /trunk.
Mostly because the Continuos Integration (CI) system will look for changes and compile /trunk.
So as long I push all my changes to trunk, the rest of the team are happy.
I decided to use 'git svn' because I like Git concept of version control and plus I think it's best practice to separate any new feature on its own branch before pushing to master(/trunk).
Like this it's guaranteed that my code won't ever break /trunk because I am always going to working on a separated branch for any new feature.
Once I am happy and I have tested the new feature, I push it to the svn /trunk where everybody can see and most importantly track all the changes that have been made.
It works for me. Hope it can be helpful for someone out there as well.
So that's my current workflow to make a SVN repository talk to Git:
1. mkdir [your_repo_folder]
2. cd [your_repo_folder]
3. git svn init [svn_repo_url] + /trunk
This will initialise the current folder for your local repo
Please note that I am pointing the folder to /trunk
OBS: I was getting the error "svn: OPTIONS 200 OK" when I tried to use the [svnrepourl] without the username info. Once I included my username into the address it worked. So in the end the address looked like this http://[username]@ [svnrepourl]
4.git svn fetch
It will pull the svn revision information from the remote repo. You should see many lines with information about svn revisions on your terminal screen
5.git checkout -b [new-feature-branch-name]
That's the new branch where you're going to work. It will be forked from master
[loop]
- you do all the changes you need
- add them
- commit them
[/loop]
once you're happy with your changes and you are ready to push to svn you do the following:
6.git checkout master
Change back to master branch
7.git merge [new-feature-branch-name] or git merge [new-feature-branch-name] -Xtheirs
Merge your changes from feature branch into master
if error Error: update-index --refresh: command returned error: 1
to fix it :
git ls-files | tr '\n' '\0' | xargs -0 git update-index --assume-unchanged
8.git svn rebase
Make sure you get most update changes from master. It rebases the commits from the upstream SVN server with your local Git master
Obs: You should only git svn rebase from your Git master and you should always do it before any git svn dcommit.
9.git svn dcommit
Commit all your changes to the remote svn repo