Select only a subset of remote git branches or display only a subset of them in gitk

If other developers drag their local branches into a shared remote repository before committing transactions (for sharing, backup, or centralized storage for access from multiple computers), is there a way to easily get only my own branches or selectively delete local links to remote branches others? If not, is there a way to show only a subset of the remote branches in gitk, so that I can see where my branches are relative to my remote branches, but does not have a graph cluttered with all the other remote branches?

+6
source share
1 answer

Here is one way to only select specific branches from a remote location:

Refs (including branches) that are retrieved from the remote are managed using the remote.<remote-name>.fetch . For example, your remote.origin.fetch is probably refspec:

 +refs/heads/*:refs/remotes/origin/* 

... this means that you can get the names of all the links in refs/heads/ in the remote repository and make them available in refs/remotes/origin/ in your local repository. ( + means forced updates, so your remote tracking branches can be updated even if the update is not fast-forward.)

Instead, you can list several refspecs that indicate specific branches to retrieve, for example. changing it like this:

  git config remote.origin.fetch +refs/heads/master:refs/remotes/origin/master git config --add remote.origin.fetch +refs/heads/blah:refs/remotes/origin/blah 

... and then next time we select only master and blah .

Of course, you already have a lot of remote tracking branches locally, and gitk will still show them. You can delete all those that do not interest you:

 git branch -r -d origin/uninteresting 
+5
source

Source: https://habr.com/ru/post/898119/