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.
我想继续使用简单的git push命令推送(几乎)所有分支,但是我希望能够在本地保留Git,而不与世界其他地方共享。
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?
我在本地保留的内容包括对公共文件的私有更改 - 因此,我想将秘密内容保存在一个没有被推送到服务器的适当命名的分支中。这是一件事吗?
2 个解决方案
#1
5
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
只需在某些命名空间中创建分支,例如private - git checkout -b private / mybranch。只要该命名空间不存在于远程仓库上,当您执行git push时,该命名空间中的任何分支都不会被推送
To also prevent pushing by explicit, set the branch.<name>.remote
to some some nonexistent remote.
要防止显式推送,请将分支。
#2
1
The only way to push more than one branch at a time is by using push.default = matching, described as: "push all matching branches. All branches having the same name in both ends are considered to be matching." That's the default setting, so maybe what you're used to. You can have a branch not pushed by naming it something that doesn't exist on the remote you're pushing to.
一次推送多个分支的唯一方法是使用push.default = matching,描述为:“推送所有匹配的分支。两端具有相同名称的所有分支都被认为是匹配的。”这是默认设置,所以也许你习惯了。您可以通过将其命名为您正在推送的遥控器上不存在的东西来推动分支。
#1
5
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
只需在某些命名空间中创建分支,例如private - git checkout -b private / mybranch。只要该命名空间不存在于远程仓库上,当您执行git push时,该命名空间中的任何分支都不会被推送
To also prevent pushing by explicit, set the branch.<name>.remote
to some some nonexistent remote.
要防止显式推送,请将分支。
#2
1
The only way to push more than one branch at a time is by using push.default = matching, described as: "push all matching branches. All branches having the same name in both ends are considered to be matching." That's the default setting, so maybe what you're used to. You can have a branch not pushed by naming it something that doesn't exist on the remote you're pushing to.
一次推送多个分支的唯一方法是使用push.default = matching,描述为:“推送所有匹配的分支。两端具有相同名称的所有分支都被认为是匹配的。”这是默认设置,所以也许你习惯了。您可以通过将其命名为您正在推送的遥控器上不存在的东西来推动分支。