git 如何禁用推送
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10260311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git how to disable push
提问by user984260
I am using git and I am doing my development work, which I don't want to push, even by mistake. Is there a method to disable push in certain local repository. One method is to rename the branch, another is to undo pushif one does it by mistake, but I hope there should be a more direct method.
我正在使用 git 并且我正在做我的开发工作,我不想推动,即使是错误的。是否有一种方法可以禁用某些本地存储库中的推送。一种方法是重命名分支,另一种方法是如果误操作则撤消推送,但我希望应该有更直接的方法。
回答by Joachim Isaksson
The following command will let pulls work, but pushes will try to use the URL no_push
and fail:
以下命令将使拉动工作,但推送将尝试使用 URLno_push
并失败:
git remote set-url --push origin no_push
回答by Fred Foo
Depending on the remote, you may be able to reset its URL to use the read-only Git protocol instead of SSH or HTTPS. E.g., for a project on GitHub, do
根据远程,您可以重置其 URL 以使用只读 Git 协议而不是 SSH 或 HTTPS。例如,对于 GitHub 上的项目,请执行
git remote set-url <remote> git://github.com/Team/Project.git
where <remote>
is commonly origin
. git remote -v
will give you a list of remotes; those that start with https
or have the form <user>@<host>:<path>
usually allow pushing.
<remote>
一般在哪里origin
。git remote -v
会给你一个遥控器列表;https
以表格开头或具有表格的那些<user>@<host>:<path>
通常允许推送。