简体   繁体   English

检查develop分支是否已合并到功能分支中?

[英]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.

相关问题 问题将Git Feature分支合并到“Beta”分支(在它已经合并到“Develop”分支之后) - Issue merging Git Feature branch into “Beta” branch (after it has already been merged to “Develop” branch) SQUASHED时检查Git分支是否已合并为主分支? - Checking if a Git branch has been merged into master when SQUASHED? 该(重新设置的)分支是否已合并? - Has this (rebased) branch been merged? GIT merge develop into feature branch -- 同一个分支被合并和恢复后 - GIT merge develop into feature branch -- after the same branch was merged and reverted 我分支了一个未合并的功能分支,但该未合并的分支现已合并 - I branched off an unmerged feature branch, but that unmerged branch has now been merged 合并后修复远程分支 - Fixing a remote branch after it has been merged 重新设置已经合并的分支 - Rebase a branch that has already been merged git:我不小心将功能分支合并到master中,而不是进行合并 - git: I accidentally merged feature branch into master instead of develop 当我需要其他分支的一些代码时如何为功能创建分支(未合并到开发分支中) - How to create branch for feature when i need some code of other branch (not merged in develop branch) 将功能分支与开发分支同步 - Sync feature branch with develop branch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM