忽略 Mercurial 中文件的未来更改,但仍对其进行跟踪

发布于 2024-11-18 20:47:18 字数 399 浏览 0 评论 0 原文

可能的重复:
Mercurial:如何忽略对跟踪文件的更改

我在 Mercurial 存储库中有一个文件,我想将其作为示例配置文件,但在开发它时,我想对其进行特定更改,但我不想跟踪它,例如数据库密码。我尝试将该文件添加到 .hgignore 中,但 Mercurial 仍然注意到修改。

我可以在 Mercurial 存储库中“跟踪”一个文件,但忽略该文件未来的本地更改而不将其从存储库本身中删除吗?

Possible Duplicate:
Mercurial: How to ignore changes to a tracked file

I have a file in a Mercurial repository that I want to have stand as an example configuration file, but while I'm developing it I want to make specific changes to it I don't want tracked, like a database password. I tried adding that file to .hgignore, but Mercurial still notices modifications.

Can I have a file "tracked" in a Mercurial repository, yet ignore future local changes to that file without removing it from the repository itself?

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

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

发布评论

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

评论(3

真心难拥有 2024-11-25 20:47:18

我认为这种功能不存在(尽管喜欢看到其他人的答案和选项:))。我使用的替代方法是将名为“config.template”的文件签入源代码管理(作为示例)。该应用程序实际上使用一个名为“config”的文件,然后我通过复制模板文件来创建该文件。然后确保“config”文件被排除在 .hgignore 文件中,这样您就不会在某个时候意外签入。

I don't think this capability exists (love to see someone else's answer with an option though :) ). The alternative I've used is to check a file into source control named "config.template" (as an example). The app actually uses a file named "config", which I then create by copying the template file. Then make sure that the "config" file is excluded in the .hgignore file so you don't accidentally check in sometime.

谁对谁错谁最难过 2024-11-25 20:47:18

不,Mercurial 中没有内置支持来自动处理这个问题,嗯......不是按照您所询问的方式。

文件有两种状态:

  • 已跟踪
  • 未跟踪

.hgignore 文件所做的唯一事情是帮助执行所有命令,这些命令仅查看所有未跟踪的文件并将它们添加到存储库(即添加它们)用于跟踪。)一旦文件被跟踪,它将始终被跟踪。

其余的留给手动处理,这意味着如果您跟踪文件,但不想提交对其的更改,则必须取消选中、忽略或以其他方式确保提交命令不会提交它,< em>每次你提交。

处理此问题的首选方法是提交模板。然后,如果可能的话,您可以在构建过程中添加一个步骤,检查实际的配置文件是否存在,如果不存在,则从模板复制一份。您确保不会跟踪此实际配置文件,并将其添加到 .hgignore 文件中。

这样,您可以更改实际的配置文件,但除非您专门将其添加到存储库,否则不会自动跟踪它,并且在提交期间无需执行任何操作。

No, there is no support built into Mercurial to automatically handle this, well... not in the way you're asking about.

There's two states of a file:

  • Tracked
  • Untracked

The only thing the .hgignore file does is to help with all the commands that just looks at all the untracked files and add them to the repository (ie. add them for tracking.) Once a file is being tracked, it will always be tracked.

The rest is left to manual handling, which means that if you track a file, but don't want to commit changes to it, you will have to uncheck, ignore, or otherwise make sure the commit command doesn't commit it, every time you commit.

The preferred way to handle this is instead to commit a template. Then, if possible, you add a step to your build process that checks if the actual configuration file is present, and if not, make a copy from the template. This actual configuration file you ensure is not tracked, and added to the .hgignore file.

This way, you can change the actual configuration file, but unless you specifically add it to the repository, it will not be tracked automatically, and there's nothing to do during commit.

千仐 2024-11-25 20:47:18

您可以在将来的提交中排除该文件。

如果您从命令行使用 hg ,这可能会很麻烦,因为您必须手动指定要提交的文件,但如果您使用类似 tortoisehg 你可以在提交表单中取消选中配置文件,它的更改不会进入更改集。

You can just exclude the file in future commits.

This can be a bother if you use hg from the command line as you would have to specify manually which files you want to commit but if you use something like tortoisehg you can just uncheck the config file in the commit form and it's changes won't go in to the changeset.

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