Skip to content

Instantly share code, notes, and snippets.

@cdeutsch
Last active May 1, 2018 21:09
Show Gist options
  • Save cdeutsch/583c12d7ad977b378325ac0eb318ad52 to your computer and use it in GitHub Desktop.
Save cdeutsch/583c12d7ad977b378325ac0eb318ad52 to your computer and use it in GitHub Desktop.
My Git aliases
[alias]
# short hand
co = checkout
br = branch
# short hand with some flags
st = status -sb
# reset all files
nuke = reset --hard HEAD
# stash all files including untracked
stashu = stash save -u
# stash all files and keep tracked files
stashun = stash save -k -u
# get short commit hash
hash = rev-parse --verify --short HEAD
# get full commit hash
hashlong = rev-parse --verify HEAD
# list tags
tags = tag -l
# list remotes
remotes = remote -v
# list branches
branches = branch -a
# remove all untracked files and directories from the working tree
trash = clean -i -d :/
# amend staged files to last commit
amend = !git commit --amend --no-edit
# stage all files and amend to last commit
amenda = !git add . && git commit --amend --no-edit
# delete merged branches
cleanup = "!git branch --merged | egrep -v '(^\\*|master|dev)' | xargs git branch -d"
# sync and then cleanup
clync = !git sync && git cleanup
# text based history graph
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
### the following assume a GitHub fork like setup regarding remotes:
## origin = your fork
## upstream = the original repo that you have forked
# checkout master, then pull upstream, then push to origin.
sync = !git checkout master && git pull upstream master && git push origin master
# do a sync, then cleanup, then rebase master on to your current checked out branch
resync = !git checkout master && git pull upstream master && git push origin master && git cleanup && git checkout - && git rebase master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment