How to create a git clone for viewing only
We're using git as our VCS for a small development team. I keep the main repository on our server as a bare git repository.
Management and people not involved with the project need to be able to see the code and documentation without knowing anything about git, so I also keep a clone on our server for browsing. To keep the clone up-to-date, I have installed a hook that updates the master branch of the clone whenever someone commits to the bare repository.
Here's the problem: some knucklehea开发者_如何学JAVAd always goes into the browsing clone and starts modifying code, which causes the master branch push operation to fail. I would like to figure out a way to either enforce a read-only policy on this one clone or figure out another way to keep it up-to-date.
The best way to deal with these situations is having a good talk with the knucklehead in question.
Otherwise the easiest is to simply use the permission system of the operating system so the files are readonly for everyone except the script which updates it from the bare repository.
You can also get reset --hard and git clean -f before pulling from the bare repo.
(Oops, sorry, did the script wipe out 2 weeks of work???? )
Why not simply provide access through gitweb, cgit or some other HTTP based repository browsing interface?
https://git.wiki.kernel.org/index.php/Gitweb
精彩评论