-
-
Save tombruijn/bc7fbdec8f704d057494cfbab475372e to your computer and use it in GitHub Desktop.
GIT find commit where branched off
This file contains hidden or 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
#!/bin/bash | |
# "master" is the name of your main branch you'll be comparing to, or you can pass the "parent" branch as an argument | |
# it compares against the current branch by default, but you can pass a second argument to specify a child branch | |
# this creates a permanent alias so you can use `git oldest-ancestor` to get the oldest ancestor of the current branch at any time | |
git config --global alias.oldest-ancestor '!zsh -c '\''diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | head -1'\'' -' |
This file contains hidden or 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
#!/bin/bash | |
# $1 is the main ancestor branch to compare to (defaults to `master`) | |
# $2 is the child branch to find the ancestor of (defaults to current branch) | |
diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | head -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment