Useful Git Aliases

I am always looking to make my life easier, quicker and typing less so I rely heavily on Keyboard Shortcuts and so the following Aliases really help me out.

I have actually decided to create this post mostly for my own benefit, but hopefully many of you may benefit from a lot of these aliases that I use day to day with git.

So here they areā€¦



Synopsis: This shows a one line log of commits with a graph, short commit hash, short date, Single Line Commit, and Author. This makes reading the logs at a glance very easy.

Usage: git hist OR git hist -5


hist = log --pretty=format:\"%C(auto)%h %ad | %s%d [%an]\" --graph --date=short #--color

Directory Difference Comparison

Synopsis: This will launch your specified difftool (for me this is BeyondCompare4) with the --dir-diff option to allow you to do a folder/directory comparison between branches/commits/staged/unstaged changes.

Usage: git dirdiff OR git dirdiff master OR git dirdiff master..somebranch OR git dirdiff --cached


dirdiff = difftool -t bc4 --dir-diff

Initial Push and Track Remote Branch

Synopsis: I use this for my initial pushes to the remote repository of a new local branch, which adds the option to Track the remote branch.

Usage: git pushy


pushy = push -u origin

Launch Merge Tool

Synopsis: Shorthand to launch my configured merge tool.

Usage: git mt


mt = mergetool

Add All Files

Synopsis: Shorthand to Add All files, including untracked files, to the staging area.

Usage: git aa


aa = add -A

Force Push Changes

Synopsis: Shorthand to force push all changes to the remote repository.

Usage: git pf


pf = push -f

Rebase Master

Synopsis: Shorthand to ReBase from the Master branch.

Usage: git rbm


rbm = rebase master

Interactively Rebase Master

Synopsis: Shorthand to ReBase from the Master branch Interactively using the -i option.

Usage: git rbm


rbmi = rebase master -i

Continue Rebase

Synopsis: Shorthand to continue with a rebase after a merge conflict has been resolved.

Usage: git rbc


rbc = rebase --continue

Abort Rebase

Synopsis: Shorthand to abort a rebase during merge conflicts.

Usage: git rba


rba = rebase --abort

Skip Rebase

Synopsis: Shorthand to skip a merge conflict during a rebase.

Usage: git rbs


rbs = rebase --skip

Checkout a New Local Branch

Synopsis: Shorthand to CheckOut a New local branch.

Usage: git con mybranchname


con = checkout -b

Checkout Master Branch

Synopsis: Shorthand to CheckOut the Master branch.

Usage: git com


com = checkout master

Commit with Message

Synopsis: Shorthand to Commit with a Message.

Usage: git cm "My Short Commit Message"


cm = commit -m

Amend the last commit

Synopsis: Shorthand to ammend the last commit.

Usage: git ca


ca = commit --amend

Delete Local Branch

Synopsis: Shorthand to Delete local Branch.

Usage: git db mybranchtodelete


db = branch -d

Force Delete Local Branch

Synopsis: Shorthand to Delete local Branch with Force.

Usage: git dbf mybranchtodelete


dbf = branch -D

Delete Remote Branch

Synopsis: Shorthand to Delete Remote Branch.

Usage: git drb mybranchtodelete


drb = push origin --delete

Delete all local branches that are merged

Synopsis: Delete all local branches that have been merged into the main branch.


cleanup = "!git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d"

Reset HEAD and Delete Changes

Synopsis: Shorthand to Reset HEAD Hard as with the --hard option which will reset your local branch back to the HEAD and remove all changes.

Usage: git rhh


rhh = reset HEAD --hard

List Branches

Synopsis: Shorthand to List local Branches.

Usage: git lb


lb = branch -vl

List Branches including remote

Synopsis: Shorthand to List Branches All which includes remote branches.

Usage: git lba


lba = branch -vla

Force Clean Branch

Synopsis: Shorthand to Clean and Force all Files and Untracked Files/Directories.

Usage: git cf


cf = clean -fd

Push Tags

Synopsis: Shorthand to Push Tags to the remote repository.

Usage: git pt


pt = push --tags

Fetch All Changes

Synopsis: Shorthand to Fetch All changes from the remote repository.

Usage: git fa


fa = fetch --all

Edit the Global Git Config

Synopsis: Shorthand to Edit your Global git Config file.

Usage: git egc


egc = config --global -e