Skip to content

Instantly share code, notes, and snippets.

@leandroribeiro
Last active March 24, 2016 14:26
Show Gist options
  • Save leandroribeiro/b3a075dd5b255dd1e8d1 to your computer and use it in GitHub Desktop.
Save leandroribeiro/b3a075dd5b255dd1e8d1 to your computer and use it in GitHub Desktop.
[alias]
# ---------------------------------
# Log commands to inspect history
#----------------------------------
# one-line log
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
# List commits showing changed files is invoked with git ll and looks like this:
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
# List with no colors if you need to chain the out put with Unix pipes:
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
# List oneline commits showing dates:
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
# List oneline commits showing relative dates:
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
# short git log
le = log --oneline --decorate
# ------------------------------------------
# Log commands to inspect (recent) history
# ------------------------------------------
# Show modified files in last commit:
dl = "!git ll -1"
# Show a diff last commit:
dlc = diff --cached HEAD^
# ------------------------------------------------
# Finding files and content inside files (grep)
# ------------------------------------------------
# Find a file path in codebase:
f = "!git ls-files | grep -i"
# Search/grep your entire codebase for a string:
grep = grep -Ii
gr = grep -Ii
# --------
# OTHERS
# --------
ci = commit --verbose
ca = commit -a --verbose
cm = commit -m
cam = commit -a -m
co = checkout
cob = checkout -b
st = status
br = branch
# list branches sorted by last modified
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
# list aliases
la = "!git config -l | grep alias | cut -c 7-"
# ADMIN FUNCTIONS ! TAKE CARE!
undo-commit = reset --soft HEAD~1
# references:
# 1. https://gist.github.com/mwhite/6887990
# 2. http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment