Skip to main content

Simple Git Aliases

·171 words·1 min·
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#

zd
Author
zd
cli-geek, strategist, architect

Related