There are lots of great docs on git elsewhere (for a few, see the links below), so I’m only including a smattering of reminders to myself in this doc. You can always read the git man pages via one of the following:

man git-branch
git help branch

or read them online at

See also:

man gittutorial
man giteveryday
man gitglossary

Running “git <foo>” executes the git-<foo> program.


Your repository is the .git directory at the top-level of your project.

A commit is a patch. The term also refers to the current state of your branch—that is, the sum of all the commits that lead to this commit. A commit has a parent commit (or none if it’s the initial commit, or more than one if it’s a merge).

The git docs draw diagrams of commit histories left to right, like so:


where C was based on B and is the latest commit.

A branch is a named reference to a commit which moves to the next commit when you make a commit to that branch. The term “branch” can also mean the lineage back in history of a given branch.

A remote is a remote repository (as opposed to the local one right in your project directory). When you clone a repository, the one you cloned from is a remote (named “origin”) to your local repository. When you clone a repository, you get all its branches too, though for your repo their names are prefixed with “origin/”, for example, “origin/this-branch” and “origin/that-branch”.

Note that if you use github and clone someone’s repo, you’ll have your own on github. If you then clone that (your) github repo to your local machine, “origin” will be your github clone. It’s customary to refer to the originally-cloned-from repo as “upstream”.

A tag is a named reference to a commit, but it it doesn’t move when you apply more commits (like a branch does).

HEAD is a reference to the current branch. When you checkout a branch, you’re moving HEAD to point to the branch specified, as well as updating the files in your project to reflect the state of that branch.

The index is a staging area you add changes to for the next commit.


# Create a new branch based on the current branch.
git branch {new-branch}
git checkout {new-branch}   # switches to new-branch
git add     # add changes to index
git add -p  # interactive
git status
git log
git rm
git mv
git fetch origin master   # get the most recent commits from origin
git merge # what are the defaults?

git push {remote} {branch}
# Ex, to push the changes on your master branch to the origin repo:
git push origin master
git push  # push the current branch to the remote branch of the same name

If you get a merge conflict, you need to manually edit the file, do a git add, then commit. git merge --abort to cancel a merge.


git reset
git reset --hard

Your .gitconfig

Straight from what Eeevee suggests, in addition to your name and email, add:

    conflictstyle = diff3

so that conflicts look like:

<<<<<<< HEAD
what you changed it to
what it was originally
what they changed it to
>>>>>>> master

(that is, the diffs also include “what it was originally”).