Skip to content

Instantly share code, notes, and snippets.

@trotter
Created February 2, 2010 20:40
Show Gist options
  • Select an option

  • Save trotter/293007 to your computer and use it in GitHub Desktop.

Select an option

Save trotter/293007 to your computer and use it in GitHub Desktop.
# The following two commands (inserted into the correct files) will let you
# easily tell what commits are on your current branch that are not on the target branch.
# Usage:
# git checkout master
# git diff-branch origin/master # Shows all unpushed changes
# git checkout my-new-feature
# git diff-branch master # Shows all commits on my-new-feature that are not on master
# In ~/.bashrc or ~/.profile
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
}
# In ~/.gitconfig
[alias]
diff-branch = !bash -l -c "'git log $(git merge-base $(parse_git_branch) $0)..HEAD $@'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment