Git learning resources

(updated: )

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

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.

Git_push_-_pull_resulting_in_merge

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.

Git_pull_-_pull_--rebase_resulting_in_linear_history

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