diff --git a/README.md b/README.md index ce3d857..22f0676 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [Show all the git-notes](#show-all-the-git-notes) * [Apply commit from another repository](#apply-commit-from-another-repository) * [Specific fetch reference](#specific-fetch-reference) +* [Find common ancestor of two branches](#find-common-ancestor-of-two-branches) @@ -973,5 +974,10 @@ git --git-dir=/.git format-patch -k -1 --stdout | git am -3 - git fetch origin master:refs/remotes/origin/mymaster ``` +## 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 4bc19e9..c4cd799 100644 --- a/tips.json +++ b/tips.json @@ -418,4 +418,7 @@ },{ "title": "Specific fetch reference", "tip": "git fetch origin master:refs/remotes/origin/mymaster" +}, { + "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" }]