For complicated branches, there might be more than one boundary. It's suggested to add a "tail -n 1" to get the last boundary.
(This command was found incorrect in some case, multiple boundary found, but the last boundary wasn't the desired one, but the second last.)git rev-list --boundary HEAD...master | grep ^- | cut -c2- | tail -n 1
Determining if a Git repository contains a particular commit - Stack Overflow
http://stackoverflow.com/questions/3506082/determining-if-a-git-repository-contains-a-particular-commit
if [ "$(git rev-parse $commitA)" == "$(git merge-base $commitA $commitB)" ]; then ...; else ...; fi"git merge-base" will also get the result of finding the branch point, for merge-base is the branch point of the two branches.
git merge-base $commitA $commitB
http://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git
git rev-list --boundary branch-a...master | grep ^- | cut -c2-
or add it to aliases in ~/.gitconfig :
[alias]
diverges = !sh -c 'git rev-list --boundary $1...$2 | grep ^- | cut -c2-'
so I can call it as:
git diverges branch-a master
沒有留言:
張貼留言