9

I'm learning about git and is using gitk to visualize my history and branches.

I tried gitk on a locally initialized repo, and it is able to show both branches that I made properly.

However, when I tried to launch gitk to visualize a repo obtained using git clone, gitk only shows one of the branches.


This is what happen:

After I did a git clone, I can see 1 branch locally:

$ git branch
* experiment

So I did git checkout -b master origin/master to create my local tracking branch, now:

$ git branch
  experiment
* master

Now I thought I'm having 2 local branches, so I happily launch gitk, however, I can only see one branch:

gitk not showing local branch

I know of a way to view the hidden master branch by doing gitk --all:

gitk only show other local branch when use with --all

But now I'm really curious why is gitk not showing the local master branch that I'm having here, does anyone have any idea?

Thanks!

Community
  • 1
  • 1
I'm a frog dragon
  • 7,865
  • 7
  • 46
  • 49

1 Answers1

17

Gitk by default only shows you the branch you are on.

It seems that when you launched gitk, your current branch was experiment. Therefore, gitk only showed you commits that lie on the experiment branch. This is the way gitk behaves by default because once you have a lot of branches, the branch names can actually be quite distracting.

gitk --all tells gitk to show all branches. At that point, gitk showed you the master.

You can create all kinds of views in gitk and you can launch it to use a pre-defined view. Checkout the "Edit View" menu entry.

Carl
  • 43,122
  • 10
  • 80
  • 104
  • I guess `gitk` is launched with different view parameters in the 2 different places I'm launching it. Thanks for pointing out that I can change the pre-defined view in "Edit View" menu, I can tune to what I wanted to see easily now. – I'm a frog dragon Mar 15 '12 at 03:57
  • Is there a way of making the default behaviour of `gitk`? – Drew Noakes Oct 02 '12 at 15:41
  • Its been a long time since I used `gitk`. You could make a git alias that launched gitk with the --all parameter. – Carl Oct 03 '12 at 06:29
  • I have `hist = !gitk --all&` in the `[alias]` part of my `~/.gitconfig`. Typing `git hist` in my prompt runs `gitk --all&`. – Gauthier Jun 11 '13 at 14:06