Question

How to make gitk show only local branches? Or even better - can I hide remote branches that do not have corresponding local branches?

Was it helpful?

Solution 3

After some experimenting I have found a solution. The following command works:

echo $(git branch) | gitk

It shows only those remote branches that have corresponding local branches. It is important to use echo $(git branch) since it forces branch to return raw list of branches instead of formatted output such as the following:

$ git branch
  develop
  release-M4.1
  vendor
* xflow

OTHER TIPS

You can create a new "View" that shows only local branches like this:

  1. Go to View -> New View... (Or press Shift-F4)
  2. In the dialog that appears, give the "View Name" something meaningful like "Local Branches"
  3. Check "All (local) Branches" in the References area
  4. Check "Remember this view" to save these settings for future launches

Now, you should see a "Local Branches" option in the View menu. Choosing this view will only show commits present in local branches. Note that you may still see remote branch labels, but only if the commit they point to is in a local branch.

Since I found this question in a search, the accepted answer didn't work for me, and I eventually found a solution that did, I figured I'd share:

gitk --argscmd='git for-each-ref --format="%(refname)" refs/heads'

It will even update if you add a branch and then refresh a running gitk with F5. You can include tags as well with:

gitk --argscmd='git for-each-ref --format="%(refname)" refs/heads refs/tags'

Or using rev-list (shorter, but slightly cheating):

gitk --argscmd='git rev-list --no-walk --branches --tags'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top