Git alias commands for faster easier version control
Switch branches/tags
Nothing to show
Clone or download
Latest commit 92e63d9 Sep 19, 2018

Git Alias

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


To see the complete code, view these files:

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 branch flows such as topic-start to create a new topic branch using master.
  • Visualizations such as graphviz to show logs and charts using third-party tools.


Download the file gitalias.txt and put it anywhere you want:

curl -O

Edit your file .gitconfig and include gitalias.txt such as:

    path = gitalias.txt

Alternative: If are using an older version of git that does not have the "include" capability, or if you prefer more control, then you can simply view the file gitalias.txt and copy/paste anything you like into your own .gitconfig file.



a = add
b = branch
c = commit

Shortcuts with options:

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


branches = branch -a
stashes = stash list


log-graph = log --graph --all  --decorate --oneline
log-standup = !git log --since yesterday --author $(git config --pretty=short


get = !git fetch --prune && git pull --rebase=preserve && git submodule update --init --recursive
put = !git commit --all --message=\"$1\" && shift && git push


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


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


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


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


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


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


You can customize any of the file items by editing the file as you like.

You can also customize any of the file items by adding your own item later in your own gitconfig file.


To include our aliases then customize "git l" with your own definition:

   path = ~/.gitconfig.d/gitalias.txt

   l = log --graph --oneline


To use better pretty formatting:

  pretty = "%H %ci %ce %ae %d %s"


To use terse status messages:

  s = status -sb


To use log summaries:

  l = log --graph --oneline


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.

More ideas

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:


We welcome people contributing, such as creating pull requests, or creating issue reports, or tweeting ideas to us.

  • We're aiming to have new kinds of pull requests open for a week to encourage comments.

We want this project to be a good starting point for teams.

  • We're aiming for consensus and practicality.

  • We want ease of use, ease of composability, and ease of understanding.

  • We use the Git documentation guidelines for our coding format.

  • We like meaningful comments and practical examples to help novices.

We prefer this git commit message format:

  • Subject
    • Start with an imperative verb, such as "Add", "Drop", "Fix", "Upgrade", etc.
    • Capitalize the line, for example "Add" not "add".
    • Limit the line to 50 characters.
    • End the line without a period.
    • Use a blank line after the subject to separate the subject from the body.
  • Body
    • Wrap the body at 72 characters.
    • Use the body to explain what and why vs. how.
    • For commits with more than one author, add "By: Alice".
    • For commits that refer to a URL, add "See:".
    • For commits that refer to a tracker, use the complete URL, not just a number or code.
  • For more info see How to write a git commit message.


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

Thanks to these people for extra help: