Git Aliases are AWESOME

When I was first programming professionally, I had a really hard time learning all the git commands. I kept a huge notebook of useful things, and later learned from Elan Kugelmass that I could store them in code as aliases. Here are some of my favourites.

placeholder

To use these in every session, put them in your .bashrc or .zshrc or whatever.

Git Aliases - for the win!

alias gst='git status'

alias gl='git log'

alias gco='git checkout'

alias gcob='git checkout -b'

alias gpb='git push origin $(git rev-parse --abbrev-ref HEAD)' # pushes to current branch

alias gpbf='git push -f origin $(git rev-parse --abbrev-ref HEAD)' # force pushes to current branch

alias gfrh='git fetch && git reset --hard origin/master' 

alias grh='git reset --hard origin/master'

alias gcam='git add . && git commit -m' #must include commit message

alias grom='git fetch && git rebase origin/master'

alias gcrh='git checkout master && git fetch && git reset --hard origin/master' 



\# make a merge request

\# see https://hub.github.com/

__make_github_pr() {

export REPOURL=$(git config --get remote.origin.url | egrep -o ':(.*).git' | cut -d : -f 2 | cut -d . -f 1)

export CURBRANCH=$(git rev-parse --abbrev-ref HEAD)

curl --silent --location --output /dev/null --write-out "%{url_effective}" -G "https://github.com/${REPOURL}/compare/master...${CURBRANCH}" | xargs open

}

alias gmr=__make_github_pr