Alexander Beletsky's development blog

My profession is engineering

Branching Workflow in Git-SVN Mode

As you might already know branches are primary power of Git. You should create branch for every task you working on. Even if it is something small you easily starting to get a good habit of creating branches, since they keep you much in isolation. So, how to deal with branches in Git-SVN mode? It is really easy and conforms to common git practices.

So, as you cloned the SVN repo you have master branch (or several masters, if you did more switches). Suppose you need to start to work on ticket ND-177.

  1. Create new branch for ND-177 (I call new branch like, original_branch-branch_name)
  2. git checkout -b master-nd-177   
    
  3. Do your work here, performing as many commits as you need
  4. get commit -a -m "some intermediate commit.."
    
  5. Now, as you are ready to be merged you to SVN, you checkout and rebase master (to get latest SVN changes from it)
  6. git checkout master
        git svn rebase
    
  7. You can simply merge 2 branches, but with simple merge you will get all commits history that you probably don’t need in SVN at all. You squash to compress number of commits into one nice looking commit object
  8. git merge --squash master-nd-177
    
  9. It would merge up all changes from master-nd-177 into master. All you need to do is commit
  10. git commit -m "ND-177 completed"
    
  11. And dcommit changes to SVN server
  12. git svn dcommit
    

That’s six basic steps makes really straightforward workflow for everyday usage.