Skip to content

Instantly share code, notes, and snippets.

@gorenje
Last active July 9, 2017 18:01
Show Gist options
  • Save gorenje/d211fc255a854151c16cadc71ded4669 to your computer and use it in GitHub Desktop.
Save gorenje/d211fc255a854151c16cadc71ded4669 to your computer and use it in GitHub Desktop.
alias gita="git add"
alias gitb="git branch"
alias gitc="git commit"
alias gitc-partial='git commit -p'
alias gitd="git diff"
alias gitdpm="git diff production/master..master/master"
alias gitl="git log"
alias gitm="git merge"
alias gitmmm="git merge master/master"
alias gits="git svn"
alias gitcp="git cherry-pick -n"
alias gitio="~/.bin/gitio"
alias gitlp="git log -p"
alias gitp="git pull"
alias gitrs="git remote show origin"
alias gitsc="git svn dcommit"
alias gitsr="git svn rebase"
alias gitst="git status"
alias gitnb="git checkout -b"
alias gits2g="git svn find-rev"
alias githome="git co master ; git svn rebase"
alias gituntrack="git rm --cached"
alias git-fetch-all="git remote | xargs -I % git fetch % && (git remote | xargs -I % git remote show %) | sed s'/* remote /################## /'g"
# alias git-fetch-all="git fetch --all"
alias gitfa=git-fetch-all
alias git-show-all="git remote | xargs -I % git remote show %"
alias git-whereis="git branch -a --contains"
function rvm_version {
if [ -x ~/.rvm/bin/rvm-prompt ] ; then
echo $(~/.rvm/bin/rvm-prompt)
else
echo " - no rvm - "
fi
}
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
local a=""
lb=${ref#refs/heads/}
local ro=$(git config --get branch.${lb}.remote || echo "origin")
local rb=$(git config --get branch.${lb}.merge)
rb=${rb#refs/heads/}
local ab=
if [ "" != "${rb}" ]; then
ab="(+$(git log --pretty=format:%H ${ro}/${rb}..${lb} | wc -w | sed s'/ //'g))"
if [ "(+0)" = "${ab}" ]; then
ab="(-$(git log --pretty=format:%H ${lb}..${ro}/${rb} | wc -w | sed s'/ //'g))"
fi
if [ "(-0)" = "${ab}" ]; then
ab=""
fi
fi
echo "("${ref#refs/heads/}")${ab}"
}
alias git-branch-prompt=parse_git_branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment