Is there any way to exclude branches from showing in GitK?

后端 未结 1 582
忘掉有多难
忘掉有多难 2021-01-12 11:10

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

1条回答
  •  执念已碎
    2021-01-12 12:09

    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.

    0 讨论(0)
提交回复
热议问题