git how to disable push

GitPush

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser984260View Question on Stackoverflow
Solution 1 - GitJoachim IsakssonView Answer on Stackoverflow
Solution 2 - GitFred FooView Answer on Stackoverflow