sh 保护远程分支免受本地回购

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 保护远程分支免受本地回购相关的知识,希望对你有一定的参考价值。

# 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.

以上是关于sh 保护远程分支免受本地回购的主要内容,如果未能解决你的问题,请参考以下文章

sh 拉所有远程分支并创建本地分支

sh 删除本地分支(不删除远程分支)

Git将分支推送到远程回购

sh 将本地分支git log与远程分支进行比较

sh 将本地分支git log与远程分支进行比较

sh 删除不再位于远程的所有本地分支