David Kuridža

Git and Mercurial behaving alike

Working with both Git and Mercurial made me realize there are some really nice features one has and the other one does not; or are just not enabled by default. Following is a short description of four things making my daily work easier, making the behaviour and output very similar with both.

Pager

Git has a pager enabled by default, to have the same behaviour in Mercurial as well, PagerExtension needs to be enabled by setting following lines in .hgrc file:

[extensions]
pager = 

[pager]
ignore = version, help, update
pager  = LESS='FSRX' less

Stash/Shelve

Although I am using stash mostly with Git, I do miss it in Mercurial from time to time. Sadly ShelveExtension is not distributed with Mercurial, but only one additional step is required. You need to download hgshelve.py and put it somewhere on your file system. After that, add following two lines to .hgrc file and you are all set:

[extensions]
hgshelve = /path/to/hgshelve.py

Colours

Neither have coloured output enabled by default, to enable default ones in Git, add following lines to .gitconfig:

[color]
        diff   = auto
        status = auto
        branch = auto
        ui     = true

Not sure why, but default Mercurial colours are not very useful for me. Therefore I am using Git's scheme, lines to be set in .hgrc are:

[extensions]
color =

[color]
status.modified = cyan
status.added    = green
status.removed  = red
status.deleted  = blue bold
status.unknown  = magenta
status.ignored  = black bold

Aliases

Mercurial knows how to deal with short commands, running hg status or hg st is the same. Git is not as smart out of the box, but by defining aliases in .gitconfig file, the same short commands for all of us lazy people are available. Basic commands for every day use:

[alias]
        co = checkout
        ci = commit
        cm = commit -m
        st = status
        br = branch

tl;dr

Well, you should :)