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:
I know of a way to view the hidden master
branch by doing gitk --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!
Use git branch -a (both local and remote branches) or git branch -r (only remote branches) to see all the remotes and their branches. You can then do a git checkout -t remotes/repo/branch to the remote and create a local branch. There is also a git-ls-remote command to see all the refs and tags for that remote.
If you run git branch in the current directory then it will return no branches as the repository is empty and the master branch will be created with the first commit.
just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With