I have some git repositories accessed remotely through SSH and I want to make some of them read-only to prevent more pushes. Some people have remotes pointing to these repos
A pre-receive hook that simply prints an informative message and exits with a non zero status does the job.
Assuming you put some meaningful information in your message, it also cuts down on the queries from frustrated users asking why they can't push:
#!/bin/bash
echo "=================================================="
echo "This repository is no longer available for pushes."
echo "Please visit blah blah yadda yadda ...."
echo "=================================================="
exit 1
Remember to set the executable permission for the script and to make sure is owned by the right user and/or group, or else it will not execute and will not give any warning.