Git:有什么方法可以防止*大多数*用户编辑文件? [英] Git: Any Way I Can Prevent *Most* Users From Editing Files?

查看:74
本文介绍了Git:有什么方法可以防止*大多数*用户编辑文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的Git存储库中,我们有大约十个非常重要的文件.这些文件被许多其他文件引用,因此,如果它们被移走,则可能会造成中断.但是由于我们如何设置开发环境,因此不会立即检测到此损坏,因此发生的情况是:1)开发人员移动了重要文件,2)他们推送了提交,3)几天后,系统管理员可以清理烂摊子.

In our Git repository we have about ten very important files. These files are referenced by lots of other files, so if they get moved stuff breaks. But because of how we have our dev environment setup, this breakage won't be detected immediately, so what happens is: 1) a developer moves an important file, 2) they push the commit, 3) a few days later our sys admin gets to clean up the mess.

为防止这种情况,我们非常想找到一种方法来限制Git存储库,以便只有某些用户才能更改这些文件.但是,我尝试搜索Stack Overflow,到目前为止,我发现的唯一解决方案是预提交钩子(或者因为我们有GitHub而没有我们自己的Git安装程序而无法使用的工具).

To prevent this we'd very much like to find a way to limit our Git repo so that only certain users can alter these files. However, I've tried searching Stack Overflow, and so far the only solution I've found are pre-commit hooks (or tools which we can't use because we have GitHub and not our own Git installation).

难道预提交的钩子(使每个人都难以使用并且很容易被禁用)是实施此类操作的唯一方法吗?还是有其他方法可以限制用户在Git中对某些文件的更改?

Are pre-commit hooks (which are a pain to get everyone to use, and can easily be disabled) the only way to enforce something like this? Or is there any other way to limit changes to certain files by user in Git?

推荐答案

您的开发团队有多大?在我看来,最简单的解决方案是:

How big is your dev team? It sounds to me like the simplest solution is:

  1. 与开发团队保持清晰的沟通,不要更改这些文件.
  2. 就像@Basile Starynkevitch所说的那样,它是一个构建时检查来快速捕获更改
  3. 如果需要,可以使用git pre-commit钩子.是的,这很容易解决,但是要这样做,他们必须明显违背传达给他们的东西.
  4. 当有人忘记并更改文件时,提醒您而又不会使团队感到羞耻.

替代解决方案
将文件放在单独的git存储库中,并为大多数团队提供只读访问权限.

Alternate Solution
Put the files in a separate git repository and give most of the team only read-only access.

这篇关于Git:有什么方法可以防止*大多数*用户编辑文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆