Skip to content

Instantly share code, notes, and snippets.



Last active Apr 3, 2020
What would you like to do?
These are a series of the Git alias I use on use on a daily basis. I have included references to the places where I have found each one to give the authors due credit.
# Source:
# Found on stackoverflow list all available aliases ==
alias = config --get-regexp '^alias.*'
s = status
ss = status --short
ssb = status --short --branch
co = commit
com = commit --message
coma = commit --all --message
# Source:
# Going to keep it a soft commit for the moment.
uncommit = reset --soft HEAD^
a = add
aa = add --all
rb = rebase
rba = rebase --abort
rbc = rebase --continue
rbs = rebase --skip
# Source:
ds = diff --staged
pr = pull --rebase
branches = branch --all
branchrename = branch --move
branchesdiffed = !git branch | grep -i "indiff"
branchesundiffed = !git branch | grep -v -i "indiff"
# Source:
# Since description is used by other git features want a different
# area for my own meta data
branchnote = !git config branch.`git rev-parse --abbrev-ref HEAD`.note
# Source:
# A better git log (subjective obviously) ==
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
# I do this often, need to see the last x number of commits ==
logn = log --max-count
# Source:
# Show running total of number of commits per dev ==
winning = shortlog --summary --numbered --email
# Source:
# The repositories running total of commits ==
total-commits = git log --all --pretty=oneline | wc -l
# Came from Conor Carr of Pilz Ireland ==
incoming = !git remote update --prune; git log ..@{upstream}
outgoing = log @{upstream}..
# Source:
unpushed = log --branches --not --remotes --decorate=full --oneline
# Wipe out all local changes you have made, be careful! ==
wipelc = checkout .
# Source:
# Source:
# Print the associated description of a branch. ==
# Set descriptions with git branch --edit-description ==
descriptionview = !git config branch.`git rev-parse --abbrev-ref HEAD`.description
descriptionedit = branch --edit-description
# Source:
commitslastmonth = !git log --author=\"`git config`\" --before={`date "+%Y-%m-01"`} --after={`date --date=\"$(date +%Y-%m-1) -1 month\" \"+%Y-%m-01\"`} --reverse --pretty=format:\"%cd %h %s\" --date=short
commitsthismonth = !git log --author=\"`git config`\" --before=now --after={`date "+%Y-%m-1"`} --reverse --pretty=format:\"%cd %h %s\" --date=short
# Source:
commitstoday = log --author=\"`git config`\" --since=\"6am\"
# Source:
todosfind = grep --extended-regexp -I --line-number --break --heading --color=auto "TODO|FIXME"
todoscount = grep --extended-regexp -I --line-number --count "TODO|FIXME"
todosnamefiles = grep --extended-regexp -I --name-only "TODO|FIXME"
# Use sublime as your default git editor
# Source:
editor = 'C:/Program Files/Sublime Text 2/sublime_text.exe' --wait --new-window
browser = c:/Program Files/Mozilla Firefox/firefox.exe
# Source:
tool = WinMergeU
[difftool "WinMergeU"]
cmd = WinMergeU.exe -e -ub -x -wl -u -maximise -dl "base" -dr "mine" \"$LOCAL\" \"$REMOTE\"
prompt = false
# Straight forward script that lists all your git branch with the age prepended at the start.
# Source:
for k in `git branch|sed s/^..//`;do
echo -e `git log -1 --pretty=format:"%Cgreen%cr%Creset" "$k"`\\t"$k";
done |sort
# bash command to list all git branch descriptions for you current repository
# Only recently discovered that git scans your scripts directory when
# searching for commands to run. You can just download this file and place
# it in your /usr/local/bin/ folder or if you are on windows, place them in a
# folder on you path. I've created a folder called git-scripts in my home folder
# and placed my scripts there. The script files need to conform to a file name
# pattern of git-<command name>. Mine is called git-description-view-all
# execute "git description-view-all" to see a list of all the branch descriptions.
branch_descriptions () {
get_branch_names | sanitize_names | pretty_print_branch_descriptions
get_branch_names () {
echo "$(git branch | grep '\w')"
# Remove the special character for the branch you are currently in and trim
# any whitespace on the branch names.
# Needs to be a clean set of strings to work with pretty print function
sanitize_names () {
echo "$(sed -e 's/\*//' -e 's/[ ]*//' $1)"
pretty_print_branch_descriptions () {
local UNDERLINE="\e[4m"
local BOLD="\e[1m"
local RESET="\e[0m"
local RED="\e[31m"
local GREEN="\e[32m"
while IFS= read -r BRANCH_NAME; do
local branchDescription="$(git config branch."$BRANCH_NAME".description)";
if [[ -n "$branchDescription" ]]
echo -e "Branch: $BOLD$RED$BRANCH_NAME$RESET";
echo -e "Description:"
echo -e "$GREEN$branchDescription$RESET"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.