Git quick reference

Reference commands for the git version-control system.

Working with commits

Abort a merge.

git merge --abort

Unstage a directory.

git rm --cached -r dir

Amend a commit message.

git commit --amend

Working with branches

Fetch remotes. This will update the list of remote branches available.

git fetch --all

Set the default upstream.

git push --set-upstream origin master
git push --set-upstream origin develop

Check out a remote branch locally.

git checkout -b master origin/master
git checkout -b develop origin/develop

Delete a local branch.

git branch -D develop

Update local branch information.

git remote update origin --prune
git branch --all

Add a remote.

git remote add private <ssh>

Change remote URL.

git remote set-url private <ssh>

Rename a remote.

git remote rename origin private

Remove a remote.

git remote rm private

Track binary data using large file storage

Git Large File Storage (LFS) replaces large files (i.e. binary files) with text pointers inside Git, and enables versioned storage of the files on a remote server. This enables offloading of versioned binary data to GitHub or an Amazon S3 bucket, for example. Note that this costs money when used on GitHub.

git lfs track "data/**"