Skip to content

Instantly share code, notes, and snippets.

@russHyde
Last active August 4, 2022 09:17
Show Gist options
  • Save russHyde/c7537b58ed0126a1ecf4c15068d0a01b to your computer and use it in GitHub Desktop.
Save russHyde/c7537b58ed0126a1ecf4c15068d0a01b to your computer and use it in GitHub Desktop.
Get in-branch changes since separating from another git branch
[alias]
biff = "!f() { \
# all changes since branch/hash $2 separated from branch/hash $1 \
old=${1:-main}; new=${2:-HEAD}; base=$(git merge-base ${old} ${new}); \
git diff ${base} ${new}; \
}; f"
[core]
editor = vim
[init]
defaultBranch = main
@russHyde
Copy link
Author

russHyde commented Aug 4, 2022

Now calling

  • git biff --> all changes between the current HEAD and the point where it diverged from main
  • git biff someBranch --> all changes between the current HEAD and the point where it diverged from someBranch
  • git biff branch1 branch2 --> all changes on branch2 since it diverged from branch1

Note that this is different from
git diff branch1 branch2
The latter gives all changes on branch2 relative to the current state of branch1.

Some other .gitconfig content is present for context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment