My Git – Svn Workflow
April 26, 2010
Leave a comment
Since updating msysgit to 1.6.5.1, I have been able to drop the custom cherrypick script I was using to commit back to my subversion repository and finally use the “proper” git – svn workflow. I’m writing it up here because every so often I forget bits of it.
My usual development workflow is based around doing all development in a topic branch.
1. Ensure master is up to date
- git svn rebase
2. Create a topic branch and switch to it
- git checkout -b [topic branch]
3. ... write some code ...
4. Commit to local git topic branch ( I use git extensions usually )
- git add .
- git commit -a -m [commit message]
When I have completed developing a feature and need to check it in to the subversion repository, I use the following workflow:
1. Ensure master is up to date
- git checkout master
- git svn rebase
2. Rebase the topic branch to master - this ensures your topic branch is a
continuation of the current master branch and will fit better with subversions
linear "view" of the world
- git checkout [topic branch]
- git rebase master
3. Merge the topic branch onto the master - because of the rebase in the
previous step creating a common ancestor, this will be a fast forward merge
- git checkout master
- git merge [topic branch]
4. Commit to the subversion repository
- git svn dcommit
5. Delete the topic branch ( assuming that the dcommit was successful,
if the dcommit failed DO NOT delete the topic branch )
- git branch -D [topic branch]
Sometimes msysgit barfs, usually when committing a large number of local commits to subversion. To fix a broken dcommit, resync the subversion master and topic branch repositories and continue with the dcommit as shown below.
1. Clean up any staged / unstaged files left by the broken dcommit
- git checkout master
- git reset head --hard
- git clean -d -f
2. Ensure the master is up to date with the subversion repository
- git svn rebase
3. Resync the master and topic branch
- git checkout [topic branch]
- git rebase master
4. Merge any remaining changes onto master
- git checkout master
- git merge [topic branch]
5. Resume committing changes to the subversion repository
- git svn dcommit
Categories: Git