Skip to content

Instantly share code, notes, and snippets.

@LucasRoesler
Created October 2, 2016 17:22
Show Gist options
  • Save LucasRoesler/a2dbbd7bbc6daa2d478d1f3ef1f1c469 to your computer and use it in GitHub Desktop.
Save LucasRoesler/a2dbbd7bbc6daa2d478d1f3ef1f1c469 to your computer and use it in GitHub Desktop.
Some helpful git aliases, add these to your ~/.gitconfig
[alias]
# common operations
cp = cherry-pick
ci = commit
co = checkout
br = branch
undo-commit = reset --soft HEAD~1
# log as a graph
graph = log --graph --oneline --decorate --all
# one-line log
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
# one-line log with list of files changed
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
# set the upstream
sup = "!f() { git branch --set-upstream-to=$1/`git symbolic-ref --short HEAD`; }; f"
# cleanup old branches
audit = "!git branch --merged | grep -v '\\*\\|master\\|develop\\|release-'"
clean-audit = "!git branch --merged | grep -v '\\*\\|master\\|develop\\|release-' | xargs -n 1 git branch -d"
# squash the currently staged files into the previous commit
# note that if you have already pushed the branch, you will probably
# need to push with `git push -f`
fixup = "!git commit --amend"
# sort branches by last update
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
# list git aliases
la = "!git config -l | grep alias | cut -c 7-"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment