How to make a git repository read-only?

前端 未结 9 859
执念已碎
执念已碎 2020-12-02 15:09

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

9条回答
  •  借酒劲吻你
    2020-12-02 16:03

    Inspired by this comment:

    1. Update your hooks/pre-receive file with the following content:

      #!/bin/sh
      
      echo "Closed for all pushes" ; exit 1
      

    This way, all users trying to push changes to this repo will receive the message above and the push will be rejected.

提交回复
热议问题