Skip to main content

Simple Git Aliases

·171 words·1 min
Posts dotFiles cli git
Table of Contents
Create shortcuts for your most-used Git commands.

Here is a short post that help making you more efficient with Git alias.

Git Alias
#

There are 2 ways to add alias:

  1. Edit the ~/.gitconfig file.
  2. Use the command line method.

Here is a demo on using the command line method to add an alias:

$ git config --global alias.st 'status -sb'

And here is a demo on using the alias:

$ git st
## main...origin/main

One it is added (with command line), you can always check all the stored aliases at the file ~/.gitconfig.

Below here is the full output with my git alias, git la or the full command git config -l | grep alias | cut -c 7-:

$ git la
ll=log --color --graph --pretty=format:"%C(yellow)%h %C(green)%ad %C(blue)|%Cred%d %Creset%s%C(cyan) [%cn]" --abbrev-commit --decorate --date=short
co=checkout
st=status -sb
last=log -1 HEAD --stat
dv=difftool -t vimdiff -y
tree=diff-tree --no-commit-id --name-only -r
la=!git config -l | grep alias | cut -c 7-
gl=config --global -l

Links#

Related

Colors with ANSI Escape Code
·364 words·2 mins
Posts ansi cli color console shell
Notes about ANSI escape code for colors.
Tunnelling with SSH Port Forwarding
·1310 words·7 mins
Posts 101 cli ssh
Quick notes on tunnelling with SSH port forwarding.
Encoding 101
·580 words·3 mins
Posts 101 cli encoding
Some notes about encoding: HTML encoding, URL encoding and ASCII encoding.