My Two Favorite Git Aliases

I’m a big fan of Git. It is a super easy-to-use version control and source code management system. Before I came to Git, though, I used Mercurial, and there were two commands that I missed. Through a lot of Googling, I came across two Git aliases that have changed everything for me: incoming and outgoing.

Usage

incoming

Command: git incoming
The Incoming command will return a nicely formatted list of incoming commits, the next time you do a pull.

outgoing

Command: git outgoing
The Outgoing command will return a nicely formatted list of outgoing commits, the next time you do a push.

Setup

To add the aliases, put the following in your .gitconfig file (typically located in your home directory):

[alias]
incoming = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' ..$(git rev-parse –abbrev-ref –symbolic-full-name @{u}))
outgoing = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' $(git rev-parse –abbrev-ref –symbolic-full-name @{u})..)
Show Comments