有什么办法可以排除在GitK中显示的分支?(Is there any way to exclude branches from showing in GitK?)

编程入门 行业动态 更新时间:2024-10-23 14:32:36
有什么办法可以排除在GitK中显示的分支?(Is there any way to exclude branches from showing in GitK?)

有时当我使用GitK时,我不关心分支上的一些提交,他们倾向于阻止我正在做的事情。

能够指定我想要的分支会很好,或者指定我想要排除的分支。

这可能吗?

Sometimes when I use GitK there's a load of commits on branches I'm not concerned with and they tend get in the way of what I'm doing.

It would be nice to be able to specify which branches I want, or specify which branches I want to exclude.

Is this possible?

最满意答案

你可以通过指定它作为gitk命令的参数来指定你想要的分支。 我假设你已经在使用 - 所有的,但你可能有兴趣知道,也有一个--not标志...虽然它有一些副作用,并且在大多数情况下不是很有用。

考虑一下如下所示的存储库:

git checkout feature-B gitk --all

在这里输入图像描述

如果你没有指定参数,你只能得到你所在的分支:

gitk

在这里输入图像描述

如果你指定多个分支,你会得到那些分支和完全合并的分支(即它们不会“伸出”)。 例如,在这里,我有feature-B , feature-C ,以及完全合并的feature-A和master ,但没有feature-D :

gitk feature-B feature-C

在这里输入图像描述

最后,您可以使用--not标志忽略分支。 但是 ,由于分支引用了所有提交给它的提交,所以--not标志将忽略您指定的分支上的提交。

gitk feature-B --not feature-D gitk --all --not feature-D feature-C

这两个都会给你:

在这里输入图像描述

在这里,提交Initial commit和1被忽略,因为它们属于分支feature-D 。 由于同样的原因,提交2也被忽略,但是显示为空提交,因为将提交3显示为分支中的初始提交是错误和误导的。 有时候这个标志会有帮助,但我通常不会使用它。

You can specify which branches you want by specifying them as arguments to the gitk command. I'm assuming that you're already using --all, but you might be interested to know that there's also a --not flag...although it has some side effects and is not too useful in most circumstances.

Consider a repository that looks like this:

git checkout feature-B gitk --all

enter image description here

If you specify no arguments, you get just the branch you're on:

gitk

enter image description here

If you specify multiple branches, you get those branches, and the branches that are fully merged (i.e. they don't "stick out"). For example, here I have feature-B, feature-C, along with the fully merged feature-A and master, but no feature-D:

gitk feature-B feature-C

enter image description here

Finally, you can use the --not flag to ignore a branch. However, since a branch refers to all the commits that lead up to it, the --not flag will ignore commits that are on the branches that you do specify.

gitk feature-B --not feature-D gitk --all --not feature-D feature-C

Both of these will give you:

enter image description here

Here, the commits Initial commit and 1 are ignored, because they belonged to branch feature-D. Commit 2 is also ignored for the same reason, but is shown as an empty commit, since it would be incorrect and misleading to show commit 3 as the initial commit in the branch. This flag can be helpful sometimes, but I don't usually find myself using it.

更多推荐

本文发布于:2023-08-07 17:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分支   有什么办法可以   GitK   showing   exclude

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!