gitgitk

Tell gitk to ignore all branches that match pattern


Suppose I have some branches with names beginning with inactive-. As their names suggest, these branches are inactive; I'm keeping around for archival purposes.

I want to tell gitk to ignore those branches, even if I also pass it the --all flag. Is there a way to do this?

Alternatively, is there some other convenient way to tell gitk to include all branches except those whose name matches inactive-*?


P.S. I did try

gitk --branches='!inactive-*'

...and variations thereof, but none worked.


Solution

  • No, there's no really convenient way to do this.

    Here's a slightly inconvenient way to achieve a similar result to "--all except for invalid-*":

    gitk $(git for-each-ref --format="%(refname:short)" refs/heads | grep -v '^inactive-')
    

    That is, we use git for-each-ref to find all branch names (everything in refs/heads/*), then use grep -v to discard those whose name starts with inactive-. The resulting list is the set of arguments to gitk.

    (You could modify gitk to do this fairly easily, since gitk is just a gigantic Tcl/Tk script.)