blog

My git aliases

In my .gitconfig:

[alias]
st = status
cm = !git add -A && git commit -m
wip = !git add -A && git commit -m 'WIP'
amend = !git add -A && git commit --amend
co = checkout
cob = checkout -b
pr = remote prune origin
br = branch
up = pull --rebase --prune origin
undo = reset HEAD~1 --mixed
upstream = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`
alias = "config --get-regexp ^alias"

Mostly taken from: https://haacked.com/archive/2014/07/28/github-flow-aliases/

Explained

git st - get status of the current branch. If I have unstaged changes etc.
git cm "message" - Stage and commit everything with passed message
git wip - Stage and commit everything with "WIP" as message
git amend - Stage and commit everything as part of previous commit
git co branch-name - Checkout existing branch
git cob branch-name - Create new branch off current branch
git pr - Prune local branches (so they don’t appear on autocomplete)
git br - List all local branches
git up - Update current branch (pull upstream changes)
git undo - Reset previous commit but keep changes (for coming back to work after doing git wip)
git upstream - Set current local branch to remote of the same name
git alias - List all git aliases in the console