-
Notifications
You must be signed in to change notification settings - Fork 97
svn to git quickstart
Leif Walsh edited this page May 17, 2013
·
2 revisions
Quick instructions for getting up to speed with git. There are plenty of tutorials for doing exactly this that go in to more depth, this will be brief. Probably start with Git - SVN Crash Course.
-
svn checkout https://svn.tokutek.com/tokudb/mongodb.org/mongodb-2.2-tokutek/
=>git clone [email protected]:Tokutek/mongo.git
-
svn copy https://.../mongodb-2.2-tokutek/trunk https://.../mongodb-2.2-tokutek/branches/7000
=>git branch 7000
-
svn up
=>git pull
-
cd ../branches/7000
=>git checkout 7000
- create a branch and switch to it at the same time with
git checkout -b 7000
- create a branch and switch to it at the same time with
-
cd ../../trunk
=>git checkout master
-
svn merge -rXXX:HEAD ../branches/7000 .
=>git merge 7000
- incorporating changes on master (trunk) into a branch (in svn, this would be create 7000b from trunk, and merge 7000 onto 7000b) =>
git checkout master; git pull; git checkout 7000; git rebase master
(if you want to rebase) orgit checkout master; git pull; git checkout 7000; git merge master
(if you want to merge recent things from master into 7000)
Probably the biggest differences between git and svn are these three:
- When you're ready to commit, you have to
git add
each file that you want to be part of this commit, and then commit it (withgit commit
). You have to do this every time you make a commit. You can usegit commit -a
to commit anything that git was tracking before that has changed, and this is similar tosvn commit
, but the idea is that you shouldn't commit something accidentally if you manually add each change. You can also add a portion of the changes in a file to a commit. - When you commit, you're just recording that commit locally. When you're ready to send things up to the server, you have to do
git push
, and if there have been changes on the server since you last did agit pull
, you'll have to dogit pull; <resolve any merge conflicts>; git push
. - Branches don't live in separate directories. The repository lives in the
.git/
folder, along with all the history and all the branches, so when you dogit checkout <branchname>
it's actually wiping out the current working directory and filling it with the other branch you're switching to, so you switch branches "in-place".
Because committing and branching are cheap, local operations, you're encouraged to branch and commit much more frequently than in svn (there are ways to merge lots of tiny commits into a larger commit for public consumption if you want), even if something's broken.