snippetbashTip
git merge-base — Find a common ancestor of two commits. More information: <https://git-scm.com/docs/git-merge-base>.
Viewed 0 times
commandfindtwoclicommitsgit merge-baseancestorcommon
Problem
How to use the
git merge-base command: Find a common ancestor of two commits. More information: <https://git-scm.com/docs/git-merge-base>.Solution
git merge-base — Find a common ancestor of two commits. More information: <https://git-scm.com/docs/git-merge-base>.Print the best common ancestor of two commits:
git merge-base {{commit_1}} {{commit_2}}Print all best common ancestors of two commits:
git merge-base {{[-a|--all]}} {{commit_1}} {{commit_2}}Check if a commit is an ancestor of a specific commit:
git merge-base --is-ancestor {{ancestor_commit}} {{commit}}Code Snippets
Print the best common ancestor of two commits
git merge-base {{commit_1}} {{commit_2}}Print all best common ancestors of two commits
git merge-base {{[-a|--all]}} {{commit_1}} {{commit_2}}Check if a commit is an ancestor of a specific commit
git merge-base --is-ancestor {{ancestor_commit}} {{commit}}Context
tldr-pages: common/git merge-base
Revisions (0)
No revisions yet.