Git learning resources

(updated: )

List of resources that will give you a good understanding of how to use Git.

Quick start summary

If you want to just get started, take a look at these links and ignore the other sections for now. You can come back later and look around some more.

  1. GitHub’s Git Handbook
  2. Making Sense of Git: Visual explanation of core Git concepts
  3. The Pro Git Book’s first three chapters. The remaining chapters go beyond the absolute basics and will be useful later on.
  4. A Visual Git Reference: Once you know a bit about how Git works, this site may solidify your understanding.

Fundamentals

Everything you need to get started.

Official documentation

Community resources

Explanations

Tips and FAQ

Teaching Git

Git internals

Misc

Example visualizations

Now some example visualizations of simple Git command combos using D3.

Apart from using them to give yourself a better understanding of how Git is manipulating the commit graph, they are great to visualize what Git does while explaining somebody how to use Git. This is much better than drawing something on paper because you can take a screenshot and they can play around with it afterwards.

Note: It is difficult to understand the final graphs and much easier, if you type in the commands yourself and see how the graph changes with each command.

pull resulting in a merge commit

Select git push on the website to get the initial setup.

This is an example of how a pull will result in a merge commit, if the local and remote branches each have commits that are not part of the other.

pull --rebase resulting in linear history

Select git pull on the website to get the initial setup.

In this scenario you based your work on the remote branch origin/master and commited your changes to your local branch master. In the meantime, at least one commit was pushed to origin/master (by somebody else). Now you cannot simply push your local commits from master to origin/master, because the commit history of origin/master is no longer a subset of master.

The easiest way to deal with this, is to rebase your local changes on top of the new changes that were introduced to orign/master. This is done via git pull --rebase respectively git pull --rebase origin master. After you resolved any merge conflicts, origin/master is now again a subset of your master allowing you to push your new commits to origin/master.

Hint: In practice you can perform an interactive rebase via git pull --rebase=interactive to see which commits will be applied. This gives you the opportunity to review what will be done and cancel/modify it, if necessary.

Remember:

  • git pull: git fetch followed by git merge
  • git pull --rebase: git fetch followed by git rebase