Git Svn survival guide
disclaimer: This is by no means intended to be an exhaustive list of everything you can and cannot do with git and svn. These are simply a subset of commands that you may find useful. To get to know more - here's a beginner's tutorial and a cheat cheet:
http://www.viget.com/extend/effectively-using-git-with-subversion/
http://myhumblecorner.wordpress.com/2011/08/25/git-svn-cheatsheet-for-git-rebels-in-an-svn-workplace/
The first commands you should use are probably:
man git
and
man git svn
Getting the code tree onto your computer
git svn clone -s https://svn.mccode.org/svn/McCode .
The option -s here means to expect a "standard" svn tree where the main trunk is called trunk, branches are in a directory called branches etc. This is the case for mccode so -s is appropriate.
Listing all existing branches
git branch -a
Update local code tree with remote changes
git svn rebase
This requires your local code tree to be clean - i.e. without uncommitted modification. If it is not - you may easily temporarily make it so with
git stash ( which is actually shorthand for git stash push)
to get your local changes back you could then do
git stash pop
To commit a change
This is 2-step process. First commit your change locally:
git commit path/to/file/to/commit
or (for all the edits present)
git commit -a
Then at some point in time you'd want to commit your local changes upstream to svn (and all the other developers) like so.
git svn dcommit
Branching
Where git really shines is branches (This is what I think anyway)
- To move between branches one does (to go to branchname):
git checkout branchname - To create a new branch:
git checkout -b newbranchname
Any changes committed while on this branch stay locally on the branch without ever involving the svn-server and thus affecting/bothering/benefitting any of the other developers. Once you've finished whatever it is your doing on your branch, you can either merge it with or rebase it onto the your current branch. To merge branch into the current branch:
git merge --squash branchname
--squash is important as you might get into a rather messy situation with commits on several branches. This is because git and svn do not handle commit metadata the same way. If you're only using git with (f.i. with github or bitbucket) then obviously this is not a problem.
This will bundle all commits in the branch into one and commit that to the local current branch. This super-commit can then be committed upstream to the svn tree using git svn dcommit. Another possibility is to do the following to get commits from branchname onto your current branch.
git rebase branchname
