# In a senario where you need changes done
# on a branch. But the remote repository
# has a lot of clones that should NOT see
# the changes happening on the branch in
# question. Then `transfer.hiderefs`
# is the answer to your problem.
# Create the protected branch on your local repo.
# This will be the branch that no other repo
# will have read or write access to.
# It will not show up on `git fetch`
# or when running `git branch --remotes`
git checkout -b protect_me
# Push this branch to the remote server.
git push origin protect_me
# ssh to the remote server where the remote
# repo is stored.
ssh <my user>@<my server>
su <my git user>
cd <my git repo>
# This is the command that will protect
# a branch from local clones (other than the
# clone that created the branch).
git config --add transfer.hiderefs ref/heads/protect_me
# Now if you clone the repo into another folder locally.
# Then from that repo run
git fetch
git branch --remotes
git branch -a
# The `protect_me` branch will not be listed as a remote
# or a local branch.