Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make gitk show only local branches?

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

like image 412
Sergiy Belozorov Avatar asked Apr 10 '12 19:04

Sergiy Belozorov


People also ask

How do I fetch a local branch?

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.

How do I see local branches with merged work?

With git branch --merged <commit> , your local list of branches will be filtered by all the branches who have been merged into a given branch or commit. Similar to above, you could type git branch --no-merged <commit> and only the branches not merged into the named commit would be listed.

How do I delete all branches except Main?

To delete all branches in Git except main, simply replace the grep for master with a grep for main: git branch | grep -v "main" | xargs git branch -D. git branch | grep -v " main$" | xargs git branch -D.

How do I remove all branches without remote?

Remove All Local Branches not on Remote First we get all remote branches using the git branch -r command. Next, we get the local branches not on the remote using the egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) command, Finally we delete the branches using the xargs git branch -d command.


3 Answers

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.

like image 81
user2032710 Avatar answered Oct 24 '22 08:10

user2032710


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'
like image 25
Daniel Woffinden Avatar answered Oct 24 '22 08:10

Daniel Woffinden


gitk --branches

It corresponds to going into "view" and checking "All (local) branches"

like image 1
Kim Avatar answered Oct 24 '22 07:10

Kim