Update for Git v2.29.0
With negative refspecs,1 added in Git v2.29, you can achieve your original intent without any changes to your coworkers’ habits.
For each coworker’s remote, add a negative refspec (i.e. prefixed with ^
) to exclude the _
-prefixed branches. This is loosely adapted from the unit test for .git/config
and the one for negative patterns. See the last line in the code block below for "Fred’s" remote.
[remote "fred"]
url = something.git
fetch = +refs/heads/*:refs/remotes/fred/*
fetch = ^refs/heads/_*
You have two options to set this for fred
on the command line:
git config --add remote.fred.fetch '^refs/heads/_*'
git remote set-branches --add fred '^refs/heads/_*'
Original answer
Expanding on VonC's excellent answer with a special "review" folder,2 you can modify your .git/config
’s entries for your coworkers’ remotes. Here is the relevant documentation.
Where it was once
[remote "fred"]
url = something.git
fetch = +refs/heads/*:refs/remotes/fred/*
You can change it to
[remote "fred"]
url = something.git
fetch = +refs/heads/review/*:refs/remotes/fred/review/*
fetch = +refs/heads/other_pattern/*:refs/remotes/fred/other_pattern/*
fetch = +refs/heads/specific_branch:refs/remotes/fred/specific_branch
After doing so, you may have to clean up the references to refs you have already fetched, but future git fetch --all
s or git fetch fred
s will not update anything outside of the patterns you specified.
1 The documentation on negative refspecs is kind of minimal and buried in a longer passage, so the best place to look is in Git's history or in VonC's answer to a different question, where he pulls the relevant parts together.
2 Or as many special or interesting folders and branches as you need.