diff --git a/README.md b/README.md index 08fea5b..171d9a0 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [Add object notes](#add-object-notes) * [Show all the git-notes](#show-all-the-git-notes) * [Apply commit from another repository](#apply-commit-from-another-repository) +* [Find common ancestor of two branches](#find-common-ancestor-of-two-branches) @@ -960,5 +961,10 @@ git log --show-notes='*' git --git-dir=/.git format-patch -k -1 --stdout | git am -3 -k ``` +## Find common ancestor of two branches +```sh +diff -u <(git rev-list --first-parent BranchA) <(git rev-list --first-parent BranchB) | sed -ne 's/^ //p' | head -1 +``` + diff --git a/tips.json b/tips.json index 89e877a..781e03a 100644 --- a/tips.json +++ b/tips.json @@ -414,4 +414,7 @@ }, { "title": "Apply commit from another repository", "tip": "git --git-dir=/.git format-patch -k -1 --stdout | git am -3 -k" +}, { + "title": "Find common ancestor of two branches", + "tip": "diff -u <(git rev-list --first-parent BranchA) <(git rev-list --first-parent BranchB) | sed -ne 's/^ //p' | head -1" }]