File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.
143143* [ Show all the git-notes] ( #show-all-the-git-notes )
144144* [ Apply commit from another repository] ( #apply-commit-from-another-repository )
145145* [ Specific fetch reference] ( #specific-fetch-reference )
146+ * [ Find common ancestor of two branches] ( #find-common-ancestor-of-two-branches )
146147
147148<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
148149<!-- @doxie.inject end toc -->
@@ -973,5 +974,10 @@ git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | git am -3 -
973974git fetch origin master:refs/remotes/origin/mymaster
974975```
975976
977+ ## Find common ancestor of two branches
978+ ``` sh
979+ diff -u <( git rev-list --first-parent BranchA) <( git rev-list --first-parent BranchB) | sed -ne ' s/^ //p' | head -1
980+ ```
981+
976982<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
977983<!-- @doxie.inject end -->
Original file line number Diff line number Diff line change 418418},{
419419 "title" : " Specific fetch reference" ,
420420 "tip" : " git fetch origin master:refs/remotes/origin/mymaster"
421+ }, {
422+ "title" : " Find common ancestor of two branches" ,
423+ "tip" : " diff -u <(git rev-list --first-parent BranchA) <(git rev-list --first-parent BranchB) | sed -ne 's/^ //p' | head -1"
421424}]
You can’t perform that action at this time.
0 commit comments