Skip to content

Instantly share code, notes, and snippets.

@grassdog
Created April 23, 2020 07:09
Show Gist options
  • Save grassdog/e1f414d84556c687a48dbfd4e2fc6ca6 to your computer and use it in GitHub Desktop.
Save grassdog/e1f414d84556c687a48dbfd4e2fc6ca6 to your computer and use it in GitHub Desktop.
Git aliases
[alias]
unstage = reset HEAD
# What's changed since last pull
news = log -p HEAD@{1}..HEAD@{0}
# Mark a repo as trusted
trust = "!mkdir -p .git/safe"
# List commits
ls = log --graph --pretty=format:"%C(yellow)%h%Cblue%d%Creset\\ %s\\ %C(green)\\ %an,\\ %ar%Creset"
# List with patches
ll = log --graph --pretty=format:"%C(yellow)%h%Cblue%d%Creset\\ %s\\ %C(green)\\ %an,\\ %ar%Creset" -p
# Log showing the graph
lg = log --all --graph --oneline --decorate
# Details of last commit
l1 = "!git ll -1"
# Grep
g = "!f() { git log -G$1; }; f"
gd = "!f() { git log -p -G$1; }; f"
# File log (diff details with commit log)
fl = log -u
# Diff a revision
dr = "!f() { git diff "$1"^.."$1"; }; f"
dtr = "!f() { git difftool "$1"^.."$1"; }; f"
# Fancy diff
fd = "!git diff --color $@ | /usr/local/share/git-core/contrib/diff-highlight/diff-highlight | less -R"
# List aliases
la = "!git config -l | grep alias | cut -c 7-"
# Safer pull
update = "!git remote update -p; git merge --ff-only @{u}"
# Wipe out current work (still creates a commit in the reflog)
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# Remove merged local branches
tidy = "!git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment