Family Portrait Of Jikishin Core In Finnish Forest
Jikishinkageryu Naginatajutsu is being practised in Finland.

Version control command aliases in Git and Mercurial

Both of Git and Mercurial can have configured shortcuts and aliases for nearly any of the native commands. These are useful in the cases when you find yourself repeating the same command over and over again.

The following examples can be written in the given configuration files. In both cases the configuration file can be found from users home directory.

Also in both cases the format of the configuration is equal, name = value. Comments can be written by starting the line with # or ;.

The examples below try to achieve same or very similar behaviour in both version control systems.

For more details about the differences and similarities between these two, can be found from Mercurial Wiki and Rosetta Stone.


Configuration file is usually called mercurial.ini or .hgrc.

# Git commands
amend = commit --amend
fetch = pull
fsck = verify

# Shortcuts
br = branch
ci = commit
co = checkout
count = log --template "{author|person}\n" | sort | uniq -c | sort
df = diff
rr = revert -a
st = !hg branch && hg status


Configuration file is usually named as .gitconfig.

# Mercurial commands
addremove = add -A
manifest = ls-tree -r --name-only --full-tree HEAD
verify = fsck

# Shortcuts
br = branch
ci = commit
co = checkout
count = !git shortlog -sn | sort
df = diff
rr = reset --hard
st = status -sb

Final thoughts

For example, both git st and hg st commands give nearly identical output. Both contain the branch in question on the first line, followed by the changed, deleted, untracked and possible new files.

The above shortcuts should give a hint of the direction on how to create more custom commands.