Little Git Tricks: Find the Last Common Commit in 2 Branches
If we want to find the newest commit that is in our main and in our feature branch, we can use this Git command:
1fe43981b856bkk8958494949494949494493339
This gives us the hash of the commit that is in both branches (in my example 1f439***). We can then see the details of that commit with git log:
Author: Johnny Graber Date: Sun Oct 22 14:07:47 2023 +0200
Cleanup before start of feature XY.
The last common commit is usually also the point in our Git history, in which we last merged our two branches.
Be aware that merge-base does a lot more behind the scenes than just answering our simple question. Read the docs, especially when you want to run this command against more than two branches.