簡體   English   中英

獲取已合並到另一個分支的分支列表

[英]Getting a list of branches that were merged into another branch

我在以一種非復雜的方式做這件事時遇到了一些麻煩...目前我可以通過輸出分支 - 從目標分支和主分支中找出合並到分支中的哪些分支,將這些命令的輸出寫入文件,然后區分這兩個文件。 有沒有人有更好的方法來獲取此信息?

例如,分支branch1,branch2和branch3都是從master中刪除的,dev開始工作。 然后,branch1和branch2合並到integrationBranch中。 該命令應該能夠告訴我branch1和branch2被合並到integrationBranch中。

編輯:

當我運行git branch --merged時,首先合並的分支總是從輸出中刪除。

例:

git checkout inegraionBranch
git merge origin/branch1
git merge origin/branch2

git branch merged
*integrationBranch
branch2

在您的示例中,您將要使用git branch -a --merged integrationBranch

兩個分支origin/branch1origin/branch2是遠程git branch ,默認情況下不會與git branch一起列出,因此除非使用-a開關,否則它們都不會顯示在輸出中。

我猜你看到branch2的原因是你可能有一個名為branch2的本地分支被合並(即,問題不在於命令正在丟棄第一個分支)

編輯:

要將所有分支合並到integrationBranch但不能合並到master您可以執行以下操作:

git branch --list -a --merged integrationBranch | sed 's/^..//;s/ .*//' | xargs git branch --list -a --no-merged master

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM