I am looking for a CLI command to achieve the following:
Get latest commit in branch x which is also in branch y
I googled around and found this:
git diff -u <(git rev-list --first-parent origin/feature/x) <(git rev-list --first-parent origin/feature/y) | sed -ne 's/^ //p' | head -1
Unfortunately, this doesn't work on my server on an alpine image and it seems super complicated. That's why I'm looking for a new solution.
Thx!
CodePudding user response:
You might want to use
git merge-base <committ-ish> <committ-ish>
(doc here)
which outputs the hash of the most recent common ancestor.
Note that <committ-ish>
here can be a commit hash as well as a branch name.