I have push access to a Git repository, but in practice I never want to push directly to that repository.
Example: I although I have push access to a Github repository, I almost always want to instead push to my fork of that repository, then submit a pull request, so that we can use the Github code review process.
How can I add that remote so that I can pull from it, but prevent myself from accidentally pushing to it?
Best I've come up with is this: note that each remote has (at least) two URLs; one for pushing and one for fetching.
If you set the push URL of a remote to the empty string, you will get an error whenever you try to push to it:
git remote set-url --push origin ""
Now,
$ git push origin master
fatal: No path specified. See 'man git-pull' for valid url syntax
It's not the most obvious error message, though.