1

我的系统管理员在文件系统的根目录放置了一个 git repo 来存储配置文件。这意味着我可以在文件系统中的任何位置添加到那个存储库。这意味着如果我的项目不存在,“git status”不会告诉我没有 repo,因为根目录始终存在。

这对我来说似乎很危险。我错了吗?

对我来说,拥有一个 git repo 是一个隐含的合同,即该目录中的所有内容都在源代码控制中(除了由于 .gitignore 而被忽略的目标文件等)。这是老派的源代码控制思想吗?

4

2 回答 2

6

这对我来说似乎很危险。我错了吗?

我认为这是令人困惑的,而不是危险的。我们已经在我工作的地方尝试过类似的方法,但最终由于您描述的原因而放弃了它。我们的解决方案是将大部分配置转移到 Puppet 中,因此我们将版本控制应用于配置管理系统,并且通常不会直接对系统进行更改。

系统管理员的一种选择是将.git目录放在其他地方,然后GIT_DIR在她需要与存储库交互时适当地设置环境变量。例如:

GIT_DIR=/etc/sysrepo.git git add /etc/someconfig.conf

这可以解决与将.git目录放在文件系统根目录相关的问题。

于 2012-05-08T17:10:25.170 回答
1

Im of the school of run the least amount of software as necessary on the server. Running git to manage changes to configuration is not a bad idea, but having the repo sitting on the root of the server is potentially dangerous in terms of hard drive space. Imagine what accidently adding a 5gb database file to the repo and doing a few commits of config files without reading the screen will do to your hard drive space.

The safer route and one I'm currently implementing is find a central location and create a repo there. Create a subfolder for each server and a shell script that can scp the /etc and any other files to and from the server to that folder. Then track them with git from there.

Ive implemented this in a few locations and it worked well. You have the obvious security issues to work out, but they are not impossible to overcome.

于 2012-05-09T00:31:11.707 回答