如何将 Mercurial 配置为不提交特定的配置文件?

发布于 2024-10-12 01:31:47 字数 603 浏览 1 评论 0原文

我的团队正在切换到 Mercurial。我们的项目都有一个配置文件(web.config 或 app.config,以及一些 bat 文件 - 我们是一家 C# 商店)。这些文件需要成为存储库的一部分。当开发人员克隆存储库时,需要对其配置文件进行本地更改才能使其正常工作。例如,项目的配置文件可能需要开发人员数据库的连接字符串或其他特定于环境的信息。我们不希望这些更改最终出现在存储库中。有时我们确实会对这些配置进行更改,这些更改确实需要进入存储库并分发给团队并最终分发给客户。

我们配置或使用 Mercurial 以使这些文件不会意外提交的最简单方法是什么?我想被迫对这些文件进行显式提交,但来自存储库的合并会自动在更新中下降。

这肯定是其他人遇到过的问题,但作为 Mercurial 新手,我们都找不到最佳解决方案。

编辑:

类似的问题可能共享一些常见的解决方案,但与此问题不同,可以在以下位置找到:Conditional Mercurial Ignore File

我将其包含在内,以防其他问题可能提供您正在寻找的答案。

My team is switching to Mercurial. Our projects all have a config file (web.config or app.config, and a few bat files as well - we are a C# shop). These files need to be part of the repository. When a developer clones the repository, local changes are needed to their config files to get them working. For example, a project's config file may need a connection string to the developer's database, or other environment-specific info. We don't want these changes ending up in the repository. And from time to time we do make changes to these configs that do need to get into the repository and distributed to the team and eventually the customer.

What is the easiest way for us to configure or use Mercurial so that these files are not getting committed by accident? I would like to be forced to make an explicit commit of such files, yet merges from the repo would automatically come down in updates.

This has to be a problem someone else has faced, but as Mercurial newbies we are all at a loss for the best solution.

Edit:

A similar question that may share some common solutions, but is not the same as this question, can be found at: Conditional Mercurial Ignore File

I am including this in case that other question might provide the answer you are looking for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不羁少年 2024-10-19 01:31:47

处理此问题的典型方法是将配置文件的模板存储在存储库中,并将实际的配置文件添加到 Mercurial 中的忽略列表中。

这样,您就可以随时获得每个配置文件的原始、未修改的副本,即使对于从头开始克隆的新开发人员也是如此,但为了使配置文件可用,您需要将其复制到实际的本地副本。配置文件名,并修改该文件。您还可以使用比较/合并程序(例如 Beyond Compare)将模板文件的新版本与旧版本的本地副本进行比较,以查看更改的内容,并添加缺少的位。

如果您需要硬阻止提交实际的配置文件,则需要一个预提交或预推送挂钩来执行此操作。

The typical way to handle this is to store templates for the configuration files in your repositor, and add the actual configuration files to the ignore list in Mercurial.

This way, you have pristine, unmodified, copies of each configuration files available at all times, even for new developers who clone from scratch, but in order to make the configuration files usable, you need to make a local copy of it to the actual configuration file name, and modify the file. You could also use compare/merge programs, such as Beyond Compare, to compare a new version of the template file with your local copy of an older version, to see what changed, and add in the missing bits.

If you need to hard prevent committing the actual configuration files, you need a pre-commit or pre-push hook that does this.

打小就很酷 2024-10-19 01:31:47

在您的 .hg/hgrc 文件中执行以下操作:(

[defaults]
commit = -X Projectname/web.config

假设“ProjectName”是项目子目录)


编辑:

另外,如果您使用的是 Tortoise HG - 也请添加此内容:(

[tortoisehg]
ciexclude = Projectname/Web.config,Projectname/App_Data/DBFile.mdf

顺便说一句请注意文件夹路径中的 FORWARD 斜杠!即使在 Windows 上也是如此!)

In your .hg/hgrc file do this:

[defaults]
commit = -X Projectname/web.config

(assuming "ProjectName" is the project subdir)


Edit:

Also, if you're using Tortoise HG - add this as well:

[tortoisehg]
ciexclude = Projectname/Web.config,Projectname/App_Data/DBFile.mdf

(by the way mind the FORWARD slash in folder-path! Even on Windows!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文