Git:如何从推送中排除仅一个分支? [英] Git: how can I exclude just one branch from push?
问题描述
我想用一个简单的 git push
命令继续推送(几乎)所有分支,但是有些事情我希望能够在本地保留在Git中而无需共享他们与世界其他地方一样.
I'd like to continue to push (almost) all branches with a simple git push
command, but there are a few things I'd like to be able to keep in Git locally without sharing them with the rest of the world.
我要在本地保存的内容包括对私有文件的私有更改 -因此,我想将秘密内容保存在一个适当命名的分支中,该分支不会不会被推送到服务器.这是东西吗?
The things I'm keeping locally include private changes to public files—hence, I'd like to keep the secret stuff in an appropriately named branch that doesn't get pushed to the server. Is this a thing?
推荐答案
只需在某些名称空间中创建分支,例如 private
- git checkout -b private/mybranch
.只要远程仓库上不存在该名称空间,当您执行 git push
Just create branches in some namespace like private
- git checkout -b private/mybranch
. As long as that namespace is not existing on the remote repo, any branch in that namespace will not be pushed when you do git push
要防止通过显式推送,请将 branch.< name> .remote
设置为一些不存在的远程对象.
To also prevent pushing by explicit, set the branch.<name>.remote
to some some nonexistent remote.
这篇关于Git:如何从推送中排除仅一个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!