Having used to type git commands won’t make us able to remember those long line commands. I always relies on git alias. I would like to share with you my favorites git aliases.

You can either type the following command to add the alias into your git config.

git config --global alias.lol "log --pretty=format:'%C(green)%h %C(red)%ad %C(cyan)%an%C(green)%d %Creset%s' --date=short --graph"
git config --global alias.recent "for-each-ref --sort=-committerdate refs/heads --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)'" git config --global alias.lg-tag "log --no-walk --tags --pretty='%h %d %s' --decorate=full" git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit

Or, you can also add new line to~/.gitconfig

Finally, to double check you can try the alias directly, or simply list them down.

$ git config --list | grep alias

alias.lg=!git lg1

alias.lg1=!git lg1-specific --all

alias.lg2=!git lg2-specific --all

alias.lg3=!git lg3-specific --all

alias.lg1-specific=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'

alias.lg2-specific=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'

alias.lg3-specific=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'

alias.lg-tag=log --no-walk --tags --pretty='%h %d %s' --decorate=full

alias.lol=log --pretty=format:'%C(green)%h %C(red)%ad %C(cyan)%an%C(green)%d %Creset%s' --date=short --graph

alias.recent=for-each-ref --sort=-committerdate refs/heads --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)'

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s