如何列出包含给定提交的分支? [英] How to list branches that contain a given commit?
问题描述
如何查询git以找出哪些分支包含给定的提交? gitk通常会列出分支,除非有太多,在这种情况下,它只是说很多(38)或类似的东西。我需要知道完整的列表,或者至少某些分支是否包含提交。 git-branch手册页面:
git branch --contains< commit>
仅列出包含指定提交的分支(如果未指定,则为HEAD) 。暗示
- 列表
。
git branch -r --contains< commit>
列表 远程跟踪分支机构 (如 user3941992 的下面的答案),即与本地分行有直接关系的分行。
- 包含标签会判断某个提交是否已经被引入分支。也许你已经从你认为已经应用的补丁获得了一个提交SHA,或者你只是想检查你最喜欢的开源项目的提交是否可以减少75%的内存使用量。
$ git log -1测试
提交d590f2ac0635ec0053c4a7377bd929943d475297
作者:Nick Quaranto< nick @ quaran。到大于
日期:周四4月1日20:38:59 2009年-0400
最后环保。
$ git branch --contains d590f2
tests
* master
注意:如果提交位于远程跟踪分支,添加 -a
选项。
(如 MichielB
git branch -a --contains< commit>
注释它只显示哪些分支包含确切提交。
如果您想知道哪些分支包含等效提交(即哪些分支已经选择提交)是 $ b
因为git cherry
比较了变更集而不是提交ID(sha1),所以可以使用git cherry
来确定您在本地提交的提交是否已在不同的提交ID下应用<上游>
。
例如,如果您通过电子邮件为补丁<上游>
提供补丁,而不是直接推或拉提交,就会发生这种情况。
__ * __ * __ * __ * __> <上游>
/
分支点
\ __ + __ + __-__ + __ + __-__ + __> < HEAD>
(这里,标记为' -
'不会显示 git cherry
,这意味着它们已经存在于< upstream>
中。)
How can I query git to find out which branches contain a given commit? gitk will usually list the branches, unless there are too many, in which case it just says "many (38)" or something like that. I need to know the full list, or at least whether certain branches contain the commit.
From the git-branch manual page:
git branch --contains <commit>
Only list branches which contain the specified commit (HEAD if not specified). Implies
--list
.
git branch -r --contains <commit>
Lists remote tracking branches as well (as mentioned in user3941992's answer below) that is "local branches that have a direct relationship to a remote branch".
See also this git ready article.
The
--contains
tag will figure out if a certain commit has been brought in yet into your branch. Perhaps you’ve got a commit SHA from a patch you thought you had applied, or you just want to check if commit for your favorite open source project that reduces memory usage by 75% is in yet.
$ git log -1 tests
commit d590f2ac0635ec0053c4a7377bd929943d475297
Author: Nick Quaranto <nick@quaran.to>
Date: Wed Apr 1 20:38:59 2009 -0400
Green all around, finally.
$ git branch --contains d590f2
tests
* master
Note: if the commit is on a remote tracking branch, add the -a
option.
(as MichielB comments below)
git branch -a --contains <commit>
MatrixFrog comments that it only shows which branches contain that exact commit.
If you want to know which branches contain an "equivalent" commit (i.e. which branches have cherry-picked that commit) that's git cherry
:
Because
git cherry
compares the changeset rather than the commit id (sha1), you can usegit cherry
to find out if a commit you made locally has been applied<upstream>
under a different commit id.
For example, this will happen if you’re feeding patches<upstream>
via email rather than pushing or pulling commits directly.
__*__*__*__*__> <upstream>
/
fork-point
\__+__+__-__+__+__-__+__> <head>
(Here, the commits marked '-
' wouldn't show up with git cherry
, meaning they are already present in <upstream>
.)
这篇关于如何列出包含给定提交的分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!