Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.4k points)

How to find the most recent common ancestor of two Git branches?

1 Answer

0 votes
by (27.5k points)

The command, git merge-base will work like a charm in this case:

$ git merge-base featureBranch developBranch

Additional info: If featureBranch is your current branch, you can use use '--fork-point' as shown below:

$ git merge-base --fork-point develop

Also, for full commit info you can use this command:

$ git log -1 $(git merge-base --fork-point develop)

Browse Categories