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 knucklehead 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?
There is no way to make a git clone read-only. There are two workarounds that will achieve a similar effect.
One way is to change the permissions of the files and the folders, so that they are read-only.
The other way I can think of is using a permission system on the server. You can use gitolite to allow read-write or read-only access to specific users/groups using the repository. There is a list of other git management software here: https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Access_control_.2F_Project_hosting