[英]Checking if develop branch has been merged into feature branch?
I have a script bumping the version and making a commit with the bump and tagging it. 我有一个脚本碰撞版本并使用凹凸进行提交并对其进行标记。 The issue I am having is making sure develop gets fetched from remote then merged into feature branch to insure no conflicts during the PR merge.
我遇到的问题是确保开发从远程获取然后合并到功能分支以确保PR合并期间没有冲突。
How do I check that the feature and develop are
in sync
merged? 如何检查功能和开发是否
同步
合并?
The git branch
command will show you branches that are merged, or are not merged. git branch
命令将显示合并或未合并的分支。 For instance, if you are on branch main
and branch side
was merged in at some point, but another branch ahead
has not yet been merged: 例如,如果您在分支
main
和分支side
在某个时候合并,但ahead
另一个分支尚未合并:
$ git branch --merged
* main
side
$ git branch --no-merged
ahead
$
It's possible (but somewhat painful) to use this to check. 使用它来检查是可能的(但有些痛苦)。 But if you just want to test one specific pair of branches (or indeed any specific pair of commits), the "is / is-not merged" quality is simply whether one is an ancestor of another, in terms of the commit graph.
但是,如果您只想测试一对特定的分支(或者实际上是任何特定的提交对),那么“is / is-not merged”的质量就是提交图表中的一个是否是另一个的祖先。
The git merge-base
command has a mode in which it performs this test, for two specific commits (which you may specify in any form listed in the gitrevisions
documentation ): git merge-base
命令有一个执行此测试的模式,用于两个特定的提交(您可以在gitrevisions
文档中列出的任何形式指定):
$ if git merge-base --is-ancestor side main; then
> echo side is merged into main
> fi
side is merged into main
$
The test that git branch --merged
uses (for each branch, comparing it to the current branch) is the same as the test git merge-base --is-ancestor
uses, ie, the SHA-1 that the first commit (here side^{commit}
) is an ancestor of the current branch's tip commit. git branch --merged
使用的测试(对于每个分支,将它与当前分支进行比较)与测试git merge-base --is-ancestor
使用的测试相同,即第一次提交的SHA-1(这里) side^{commit}
)是当前分支提示的祖先。 (A commit is considered an ancestor of itself, so you always get your own current branch from git branch --merged
. Assuming of course that you are on a branch in the first place—if you're in "detached HEAD" state, the list of all named branches does not include your detached HEAD.) (提交被认为是它自己的祖先,所以你总是从
git branch --merged
获得你自己的当前分支git branch --merged
。当然假设你在一个分支上 - 如果你处于“超级HEAD”状态,所有已命名分支的列表不包括已分离的HEAD。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.