git how to disable push [duplicate]

时间秒杀一切 提交于 2019-12-17 21:24:35

问题


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 push if one does it by mistake, but I hope there should be a more direct method.


回答1:


The following command will let pulls work, but pushes will try to use the URL no_push and fail:

git remote set-url --push origin no_push



回答2:


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

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.



来源:https://stackoverflow.com/questions/10260311/git-how-to-disable-push

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!