Skip to content

Instantly share code, notes, and snippets.

@albsen
Created October 3, 2011 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albsen/1258372 to your computer and use it in GitHub Desktop.
Save albsen/1258372 to your computer and use it in GitHub Desktop.
gbin gbout bash functions I couldn't work without
#
# I didn't write those, ;) all props go to http://stackoverflow.com/users/110735/clint-modien
#
# The following bash functions show you the difference in commits between the branch you are on
# and another branch that you either want to commit too or merge from.
#
# USAGE:
# gbout branch_i_want_to_push_too [-p, --raw]
# gbin branch_i_want_to_pull_from [-p, --raw]
#
# OPTIONS:
# -p shows full diffs with code
# --raw shows committed files
#
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function gbin {
echo branch \($1\) has these commits and \($(parse_git_branch)\) does not
git log ..$1 --no-merges --format='%h | Author:%an | Date:%ad | %s' --date=local $2
}
function gbout {
echo branch \($(parse_git_branch)\) has these commits and \($1\) does not
git log $1.. --no-merges --format='%h | Author:%an | Date:%ad | %s' --date=local $2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment