Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Git Alias

This project provides many git alias commands that you can use as you like.



What is Git Alias?

Git Alias is a collection of git version control shortcuts, functions, and commands:

  • Shortcuts such as s for status.

  • Improvements such as optimize to do a prune and repack with recommended settings.

  • Topic workflows such as topic-start to create a new topic branch for a feature or fix.

  • Visualizations such as graphviz to show logs and charts using third-party tools.

Where is the code?

To see the complete code, view this file:

Why use this?

We are creating this alias list because we type these commands many times daily, and we want the commands to be fast and also accurate.

We often work on teams, across many companies and organizations, and using multiple shells. We want to count on a set of aliases. For shorter commands, such as s for status, fast speed is nice. For longer commands, such as repacker, accurate settings are important.


Download the file gitalias.txt:

curl -O

Typical usage for a typical user:

  • Save this file as a dot file in your home directory: ~/.gitalias.txt

  • git config --global include.path ~/.gitalias.txt in terminal. Or manually edit your git config dot file in your home directory such as ~/.gitconfig, include the path to this file.

Example file ~/.gitconfig with an entry to include the file ~/.gitalias.txt:

  path = gitalias.txt


Shortcut examples


a = add
b = branch
c = commit

Letters with options:

ap = add --patch
be = branch --edit-description
ci = commit --interactive

Popular examples


dd = diff --check --dirstat --find-copies --find-renames --histogram --color
ll = log --graph --topo-order --abbrev-commit --date=short --decorate --all --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn]%Creset %Cblue%G?%Creset'


cam = commit --amend --message
rbi = rebase --interactive @{upstream}

Accelerator examples


log-graph = log --graph --all  --decorate --oneline
log-my-week = !git log --author $(git config --since "1 week ago"


grep-group =  grep --break --heading --line-number
grep-all = !"git rev-list --all | xargs git grep '$1'"

Recovery examples


uncommit = reset --soft HEAD~1
cleanout = !git clean -df && git checkout -- .


snapshot = !git stash push "snapshot: $(date)" && git stash apply "stash@{0}"
archive = !"f() { top=$(rev-parse --show-toplevel); cd $top; tar cvf $top.tar $top ; }; f"

Coordination examples


ours   = !"f() { git checkout --ours $@ && git add $@; }; f"
theirs = !"f() { git checkout --theirs $@ && git add $@; }; f"


incoming = !git remote update --prune; git log ..@{upstream}
outgoing = log @{upstream}..

Workflow examples


get = !git fetch --prune && git pull --rebase=preserve && git submodule update --init --recursive
put = !git commit --all && git push


publish = "!git push -u origin $(git branch-name)"
unpublish = "!git push origin :$(git branch-name)"


topic-start = "!f(){ b=$1; git checkout master; git fetch; git rebase; git checkout -b "$b" master; };f"
topic-stop = "!f(){ b=$1; git checkout master; git branch -d "$b"; git push origin ":$b"; };f"

Optimization examples


top-name = rev-parse --show-toplevel
branch-name = rev-parse --abbrev-ref HEAD
upstream-name = !git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)


branches = branch -a
stashes = stash list
tags = tag -n1 --list


pruner = !git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all
repacker = !git repack -a -d -f --depth=300 --window=300 --window-memory=1g
expunge = !"f() { git filter-branch --force --index-filter \"git rm --cached --ignore-unmatch $1\" --prune-empty --tag-name-filter cat -- --all }; f"


If you want to use this file, and also want to change some of the items, then one way is to use your git config file to include this gitalias file, and also define your own alias items; a later alias takes precedence.

This section has examples that include this file, then add a customization.


To do your own custom terse status messages:

   path = .gitalias.txt
  s = status -sb


To do your own custom log summaries:

   path = .gitalias.txt
  l = log --graph --oneline


To do your own custom pretty formatting:

   path = .gitalias.txt
  pretty = "%H %ci %ce %ae %d %s"


See also

More ideas for git improvements:

  • If you want to alias the git command, then use your shell, such as alias g=git.
  • If you want history views, see git-recall
  • If you use oh-my-zsh, then you may like the git plugin
  • If you use vim then see Fugitive
  • If you use emacs then see Magit
  • If you use git shell scripting then see SCM Breeze
  • If you use node then see git-alias

For more git config ideas, and for credit for many of the aliases here, please see these excelent resources:


To do

To do list in priority order:

  • Create an alias that helps remove problem files, akin to bfg.

  • Create installable packages such as for apt, brew, dnf.

  • Create completion file for bash, zsh, etc.

  • Create CI/CD pipeline.

  • Create security checksum.

  • Create announcement list.

  • Request comments from git thought leaders.

  • Create aliases for GitPrime metrics suggestions: unreviewed pull requests, new work percentage, legacy refactor percentage, active days, time to first comment, churn, time to resolve.


Thanks to all the contributors, including all the creators of the projects mentioned above.

Thanks to these people for extra help, in order of participation:


Git alias commands for faster easier version control



No releases published


No packages published
You can’t perform that action at this time.