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.
- GitHub’s Git Handbook
- Making Sense of Git: Visual explanation of core Git concepts
- The Pro Git Book’s first three chapters. The remaining chapters go beyond the absolute basics and will be useful later on.
- Chapter 1: Getting Started
- Chapter 2: Git Basics
- Chapter 3: Git Branching
- 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.
- learngitbranching.js.org: Interactive Git lessons teaching you the basics.
- Visualizing Git Concepts resp. visualizing Git commands.
Have a look at the example visualizations and try them out yourself—it’s fun. - The Pro Git Book’s first three chapters. The remaining chapters go beyond the absolute basics and will be useful later on.
- Chapter 1: Getting Started
- Chapter 2: Git Basics
- Chapter 3: Git Branching
Official documentation
- Git SCM Docs: Command reference manual, cheat sheets, “Pro Git book”, videos.
- Git SCM external links: Curated, ever-evolving collection of tutorials, books, videos, and other Git resources.
- Git SCM Wiki
Community resources
Explanations
- The simple guide
- The Git parable: Mental creation of a Git-like system from the ground up. Explains the function of each part and how they complement each other.
- Git pretty: Workflow chart
- Making Sense of Git: Visual explanation of core Git concepts
- Git Cheatsheet Interactive Git Cheatsheet, categorizing commands based on what they affect.
- A Visual Git Reference: Once you know a bit about how Git works, this site may solidify your understanding.
- Git concepts simplified (slides)
- Git from the bottom up
- Think Like (a) Git: A guide for the perplexed.
- Practical Git introduction
Tips and FAQ
- Git tips: Common questions and their solutions
- GitHub Cheat Sheet: Tips for working with GitHub
- Oh, shit, git!: How to get out of difficult situations
- Git Flight Rules Detailed “if x then y”
Teaching Git
Git internals
Misc
- try.github.io
- GitHub’s Git Handbook
- Git Exercise Learn and practice (source)
- Learn Git Branching (source)
- gittutorial.txt
- giteveryday.txt
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 bygit merge
git pull --rebase
:git fetch
followed bygit rebase