How to make gitk show only local branches? Or even better - can I hide remote branches that do not have corresponding local branches?
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.
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.
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.
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.
You can create a new "View" that shows only local branches like this:
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'
gitk --branches
It corresponds to going into "view" and checking "All (local) branches"
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