MPOV

occasional posts about programming, tech, and the dreaded etcetera

Git for People Who Know Svn, Part 2

For Part 2 of our 60-second Git tutorial, we’ll look at some super simple branching and merging.

git branch tells you which branch you’re on.

git branch -a lists all branches, even remote ones.

git checkout mybranch checks out the branch you want.

git checkout -b newbranch creates a new branch from the one you’re on, and checks it out for you.

git checkout master && git merge mybranch merges changes from one branch to your master branch. If you don’t yet want to commit the changes, you can do git merge --no-commit mybranch instead.

So far, we’ve only talked about local git usage. Isn’t it cool that you can do so much without even having a server set up with our repo? I think so.

Part 3 will include pulling and pushing your changes to remote repos.

Update: Yeah, ok, so I never got around to writing part 3. Back when this was written, super simple Git how-tos were less plentiful. Now, we have git-scm.com, Why Git is Better than SVN, and of course GitHub’s help site.