开发者

Reference Git branch start commit

开发者 https://www.devze.com 2022-12-22 22:56 出处:网络
I am trying to find how to reference branch start commit from script. I mean the commit sha at which branch was forked.

I am trying to find how to reference branch start commit from script. I mean the commit sha at which branch was forked.

Moreover I expect it work for history made f开发者_JAVA百科rom svn repo.

This post just gives first commit of repo creation and not feature branch start commit.


What you're looking for is the command merge-base:

git merge-base master feature-branch

will print the best common ancestor of those two branches, i.e. where they forked apart. (The documentation has pretty pretty pictures to clarify some of the interesting cases)

An additional tidbit is you can add the merge-base flag --fork-point to automatically include the name feature-branch, read more in this answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消