Last active
July 2, 2021 17:30
-
-
Save jimmyhchan/1745074c42e75189eacbc21f8b333dfd to your computer and use it in GitHub Desktop.
aliases for git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HEY DO THIS | |
# ... add this to your .bash_profile | |
# if [ -f ~/.bashrc ]; then | |
# source ~/.bashrc | |
# fi | |
# bash completion | |
if [ -f /usr/local/etc/bash_completion ]; then | |
. /usr/local/etc/bash_completion | |
fi | |
[ -d /usr/local/etc/bash_completion.d ] && . /usr/local/etc/bash_completion.d/* | |
export EDITOR="vim" | |
alias gb='git branch -v' | |
alias gs='git status' | |
alias gd='git diff' | |
alias gl='git log' | |
alias gdd='git diff --cached' | |
alias ga.='git add .' | |
alias gpr='git pull --rebase' | |
alias grc='git rebase --continue' | |
# gc => git checkout main | |
# gc bugs => git checkout bugs | |
function gc { | |
# remoteHead=`git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'` | |
remoteHead=`git remote show origin | awk '/HEAD branch/ {print $NF}'` | |
if [ -z "$1" ]; then | |
git checkout $remoteHead | |
else | |
git checkout $1 | |
fi | |
} | |
__git_complete gc _git_checkout | |
function gcob { | |
if [ "$1" ]; then | |
#remoteHead=`git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'` | |
remoteHead=`git remote show origin | awk '/HEAD branch/ {print $NF}'` | |
git checkout -b $1 ${2:-$remoteHead} | |
fi | |
} | |
__git_complete gcob _git_checkout | |
function gri { | |
remoteHead=`git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'` | |
git rebase -i ${1:-$remoteHead} | |
} | |
alias gitdiff='git diff --color-words' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment