If other developers push their local branches to a shared remote repository before committing to trunk (to share, backup, or centrally store them for access from multiple machines), is there a way for me to easily only fetch my own branches or selectively delete local references to others’ remote branches? If not, is there a way to only show a subset of remote branches in gitk, so I can see where my branches are relative to my remote branches, but not have the graph cluttered by everyone else’s remote branches?
If other developers push their local branches to a shared remote repository before committing
Share
Here’s one way of only fetching particular branches from a remote:
The refs (including branches) that are fetched from a remote are controlled with the config option
remote.<remote-name>.fetch. For example, yourremote.origin.fetchis probably the refspec:… which means to make fetch the names of all the refs under
refs/heads/in the remote repository, and make them available underrefs/remotes/origin/in your local repository. (The+means to do forced updates, so your remote-tracking branches can be updated even if the update wouldn’t be a fast-forward.)You can instead list multiple refspecs that specify particular branches to fetch, e.g. changing this with:
… and then the next time only
masterandblahwill be fetched.Of course, you already locally have lots of remote-tracking branches, and
gitkwill still show those. You can remove each of the ones you’re not interested in with: