Git git-svn Working locally


Just use your local git repository as a normal git repo, with the normal git commands:

  • git add FILE and git checkout -- FILE To stage/unstage a file
  • git commit To save your changes. Those commits will be local and will not be "pushed" to the SVN repo, just like in a normal git repository
  • git stash and git stash pop Allows using stashes
  • git reset HEAD --hard Revert all your local changes
  • git log Access all the history in the repository
  • git rebase -i so you can rewrite your local history freely
  • git branch and git checkout to create local branches

As the git-svn documentation states "Subversion is a system that is far less sophisticated than Git" so you can't use all the full power of git without messing up the history in the Subversion server. Fortunately the rules are very simple: Keep the history linear

This means you can make almost any git operation: creating branches, removing/reordering/squashing commits, move the history around, delete commits, etc. Anything but merges. If you need to reintegrate the history of local branches use git rebase instead.

When you perform a merge, a merge commit is created. The particular thing about merge commits is that they have two parents, and that makes the history non-linear. Non-linear history will confuse SVN in the case you "push" a merge commit to the repository.

However do not worry: you won't break anything if you "push" a git merge commit to SVN. If you do so, when the git merge commit is sent to the svn server it will contain all the changes of all commits for that merge, so you will lose the history of those commits, but not the changes in your code.