git - 防止 git 推送到所有分支

标签 git

我想阻止 git push 和 pull 到所有远程分支。我知道开关 --all 并且我希望当我设置这个开关时 git 只会推送到 all 。

当我输入 git remote show origin 时,我看到我所有的本地分支都配置为 git pull 并推送到远程分支。

但我更喜欢这样,当我输入没有origin branchnamegit pull 时,git 只会推送实际的分支。

有没有我可以更改此行为的配置开关?

最佳答案

考虑新的default push policy ,你可以尝试设置:

git config push.default upstream
# or
git config push.default simple
# or
git config push.default current

这三个都只用于推送当前分支。

正如我在“git - push current vs. push upstream (tracking)”中所解释的那样:

Pushing only one branch (with the mode "simple", "current" or "upstream") avoids the scenario where all matching branches are pushed ("default "matching"), even though some of the branches are not ready to be pushed.

关于git - 防止 git 推送到所有分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15597959/

相关文章:

git - 如何在 StGit 中拆分补丁?

git - 如何控制 Handlebars 如何生成换行符?

git - 如何从 Git 存储库的提交历史记录中移除/删除大文件?

git - svn 到 git 的转换 : Correct remote ref must start with 'refs/' error

git - 为 github 项目做贡献时代码缩进

Git - 远程头未正确更新

java - 在 Windows 10 上安装 Android Studio 的问题

git - 在 github 中创建的文件与推送到 github 的文件之间的区别?

git - Azure Devops Repos - 恢复到以前的提交,就像最近的提交从未存在过一样

c# - Visual Studio 在哪里存储发布配置文件?