My git essentials

My git essentials

Aliases

I add the following to the bottom of my ~/.gitconfig

[alias]
    st = status
    ci = commit
    co = checkout
    br = branch --sort=committerdat

This allows me to do command like git st or git br instead of git status and git branch.

Destructively reset branch to remote

When my development branch is in complete disarray, I reset to the remote. I only do this know I have my work on other branches as this command is destructive.

git co development
git reset --hard origin/development

Delete merged branches

This will remove any branches that have been merged but will make sure ‘master’ and ‘development’ are not removed

git branch --merged | grep -v "\*" | grep -v develop | grep -v master | xargs -n 1 git branch -d