Git is an incredibly powerful tool. Sometimes all that power makes it difficult to remember the myriad command-line options required to fit your workflow. Configuring aliases can help make these much more accessible.

Global git aliases live in the [alias] section of your user configuration file (~/.gitconfig).

Simple Shortcuts

Save yourself some typing when performing commonplace tasks:

co = checkout
ci = commit
br = branch
s = status
dt = difftool

Delete Branch (Locally and Remotely)

When working with GitHub Pull Requests and personal repositories there’s no automatic mechanism for deleting the pull request branch from your repository. This alias will delete both the local and remote branches in just one command:

delete-branch = "!git branch -D $1; git push origin :$1"

Single Diff

Generate the diff for a single change set:

diff-single = diff-tree --patch --no-commit-id --cc

List Commits

Sometimes it’s useful to be list just the SHA1s associated with all the changes on your current branch:

list-commits = log --pretty=format:"%H"