开发者

Git: how can I exclude just one branch from push?

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 开发者_如何学Go 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?


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

To also prevent pushing by explicit, set the branch.<name>.remote to some some nonexistent remote.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜