gitk display only specified branches gitk display only specified branches git git

gitk display only specified branches


gitk v0.8.x v0.9.x does it for me.

However, a closer look on the displayed branches shows me that there are actually not the given branches displayed. In addition, all branches that point to a commit in the history of the two branches are also shown.

So, the command displays all branches that are specified including those branches that are direct ancestors of the ones specified.


Edit:

The --branches= switch would be used if you want to see all branches that are, for example, named fix/*:

gitk --branches=fix/*

would show you all branches that are matching the given shell glob.

See also the docs of gitk for a deeper explanation.


I was unable to get the --branches[=<pattern>] argument to work (for any shell glob, but especially for multiple globs). Fortunately, you can accomplish the same with a whole bunch of unix piping.

git branch -r | egrep "origin/(testing|prod|dev)" | xargs | tr '\n' ' ' | xargs -I {} bash -c 'gitk {}'

Breakdown:

  • git branch -r -- show all remote branches

  • egrep "origin/(testing|prod|dev)" -- filter to those that start with testing*, prod*, or dev*.

  • First xargs -- easy way to trim

  • tr '\n' ' ' -- combine all results into a single space-separated line

  • xargs -I {} bash -c 'gitk {}' -- pipe that line into gitk