Useful shell aliases for git

There are a lot of steps I end up doing with git repeatedly, especially when using a pull request workflow, so I make shell aliases out of them (either bash or zsh).   Some could be just as easily done as git aliases if you prefer.

Fixup a new git add into the last commit

alias gfixup="git commit --amend -C HEAD"

Remove all local branches that have been merged into master, production, or integration

alias gremoveMerged='git branch --merged | grep -v "\*" | grep -v master | grep -v production | grep -v integration | xargs -n 1 git branch -d'

Diff staged files

alias gstaged='git diff --staged'

Call the log with the --oneline flag

alias glog="git log --oneline"

Rebase current branch to the tip of some other branch

alias gbase-master='git checkout master && git pull && git checkout - && git rebase master'

alias gbase-integration='git checkout integration && git pull && git checkout - && git rebase integration'

alias gbase-7x='git checkout 7.x-1.x && git pull && git checkout - && git rebase 7.x-1.x'

 

section: