Find common ancestor of two branches

This commit is contained in:
Steve Binkowski 2016-09-28 12:37:48 -04:00
parent 59de6a8b80
commit d2bf9e8c63
2 changed files with 9 additions and 0 deletions

View File

@ -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)
<!-- Dont remove or change the comment below that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
<!-- @doxie.inject end toc -->
@ -960,5 +961,10 @@ git log --show-notes='*'
git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | 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
```
<!-- Dont remove or change the comment below that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
<!-- @doxie.inject end -->

View File

@ -414,4 +414,7 @@
}, {
"title": "Apply commit from another repository",
"tip": "git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | 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"
}]