参考 Git 分支开始提交 [英] Reference Git branch start commit

查看:27
本文介绍了参考 Git 分支开始提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到如何从脚本中引用分支开始提交.我的意思是分支被分叉的提交 sha.

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

此外,我希望它适用于 svn repo 制作的历史记录.

Moreover I expect it work for history made from svn repo.

这篇文章只给出了第一次提交存储库创建而不是功能分支开始提交.

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

推荐答案

您正在寻找的是命令 merge-base:

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)

这篇关于参考 Git 分支开始提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆