Git cheatsheet

See all local branches

git branch

See all remote branches

git branch -r

See all branches

git branch -a

Clone a git repo

git clone [url]

Create a local branch from remote and switch to it

git checkout -b <branch> <remote>/<branch>

List the current configured remote repository for your fork.

git remote -v

List recent commits

git log

Add a new remote upstream repository

git remote add upstream [url]

See what files are changed

git status

See only changes that have already been added to the Staging Area

git diff --staged

Show unstaged changes

git diff

Push to remote

git push <remote> <branch>

Check out pull requests locally

In .git/config add this under the [remote “upstream”] section

fetch = +refs/pull/*/head:refs/remotes/origin/pr/*:

To check out a particular pull request:

git checkout pr/999

Excellent Git resources