git-merge-base:tldr:0a2eb
The git merge-base
command is used in Git to find the common ancestor of two git branch heads or commits.
In the given command, ${commit_1}
and ${commit_2}
are placeholder variables representing the two commits or branch heads whose common ancestor you want to find.
When you run the command git merge-base ${commit_1} ${commit_2}
, Git identifies the common ancestor commit (if any) between the two specified commits.
The output of this command will be the commit hash of the common ancestor. If there is no common ancestor between the specified commits, it will simply return an empty output.
This command is often used in scenarios where you want to find the point at which two branches diverged from each other, or to determine the base commit for a feature branch that you want to merge back into the main branch.