如何创建仅供查看的 git 克隆
我们使用 git 作为小型开发团队的 VCS。我将主存储库作为裸 git 存储库保留在我们的服务器上。
管理层和不参与该项目的人员需要能够在不了解 git 的情况下查看代码和文档,因此我还在我们的服务器上保留了一个克隆以供浏览。为了使克隆保持最新,我安装了一个钩子,每当有人提交到裸存储库时,该钩子就会更新克隆的主分支。
问题是这样的:一些笨蛋总是进入浏览克隆并开始修改代码,这会导致主分支推送操作失败。我想找出一种方法来对这个克隆强制执行只读策略,或者找出另一种方法来使其保持最新。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
处理这些情况的最好方法是与有问题的笨蛋好好谈谈。
否则,最简单的方法是简单地使用操作系统的权限系统,以便除了从裸存储库更新文件的脚本之外,文件对每个人都是只读的。
在从裸存储库中拉取之前,您还可以重置 --hard 和git clean -f。
(哎呀,抱歉,这个脚本毁掉了两周的工作吗???)
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???? )
为什么不简单地通过 gitweb、cgit 或其他一些基于 HTTP 的存储库浏览界面提供访问权限?
https://git.wiki.kernel.org/index.php/Gitweb
Why not simply provide access through gitweb, cgit or some other HTTP based repository browsing interface?
https://git.wiki.kernel.org/index.php/Gitweb