When I learned git and switched from SVN to git I had a lot of questions. After reading a lot of tutorials and getting warm with the commandline I still had another problem: how to do the command line commands in tortoise? Tortoise is still really cool for windows users, because it integrates so nicely with the windows explorer. But some features are a little bit hidden:

svn update

The SVN workflow is often simpler than git, so often the order is like this:

  1. modify a file in your repository
  2. try to commit it
  3. notice that the working copy needs an update first
  4. do an update and merge the conflicts
  5. recommit

In the latest gui versions from tortoise svn these steps are bundled nicely: The SVN commit tool will parse the error line for "you have to update your working copy first" and will suggest to make an update. After the update (merge) has suceeded it opens the commit dialog again (with the previously entered commit message pre filled).
But how would this workflow would look like in git?

git pull and rebase

What I've learned is: If you always pull your changes to a git repository without working dir changes it's likely that git can fast forward your head branch. (You can read a really nice article if your familiar with graphs visual git guide about the topic). Fast forward is a good thing and merging is not such a good thing (You'll notice that the other team members of github will ask you to rebase your commits if you have too much merges in your history).

So if you haven't screwed up yet, go to the pull dialog an ALWAYS check: only fast forward. (this is --only-ff in the console). If you have screwed up, you'll get an error message: "branch xxx does not fast forward branch yyyy". This is aquivalent to "you have to update your working copy first" in SVN. When you tried to push I assume that you have commited everything. You will see your local commits in tortoise sync on your branch. Now go to the fetch dialog and tick launch rebase after fetch. If you have tracked your remote branch the following will happen:

  • git will fetch the remote and compare the commits
  • git will start rebase and will put your local commits after the latest commit fetched from remote

The flow is like this:

  1. goto git -> fetch dialog (check: rebase after fetch)
  2. close fetch window after fetching
  3. click rebase (you will see your commits listet at the top of the window as picked)
  4. you are able to push after closing the rebase window

You'll see that you're local history is like you expected it in svn.