Mercurial 暂时忽略版本化文件
我的问题本质上与 此处但适用于 Mercurial。我有一组受版本控制的文件,一个保存操作会更改相当多的文件。由此产生的一些更改对于版本控制很重要,而另一些更改只是垃圾。我可以将垃圾“分区”成单独的文件。这些垃圾文件需要成为基本检出的一部分才能正常工作,但它们的内容(以及随时间的变化)对于版本控制来说并不那么重要。现在,我只是告诉所有开发人员不要提交这些文件,但我们都忘记了,这在存储库中造成了很多额外的负担。我不太喜欢提出的 svn 解决方案,因为有相当多的文件,而且我想要一个简单的克隆来工作,而不需要所有这些额外的手动工作,所以我想知道 Mercurial 是否有更好的替代方案。它有点像 hg shelve 但不完全一样,有点像ignore,但又不完全一样。是否有一些 hg 扩展允许这样做? git 可以吗?
My question is essentially the same as here but applies to mercurial. I have a set of files that are under version control, and one save operation changes quite a lot of files. Some of the resulting changes are important for revision control, and some of the changes are just junk. I can "partition" off the junk into separate files. These junk files need to be part of a basic checkout in order for it to work, but their contents (and changes over time) aren't that important for revision control. Right now I just tell all our developers not to commit these files, but we all forget and it creates a lot of extra baggage in the repository. I don't really like the svn solution proposed because there are quite a lot of files and I want a simple clone to just work without all this extra manual work, so I was wondering if mercurial has a better alternative. It's kind of like hg shelve but not quite, and kind of like ignore, but not quite. Is there some hg extension that allows for this? Can git do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Mercurial 不支持这一点。正确的方法是提交
thefile.sample
,然后让您的开发人员(或者更好的是部署脚本)从thefile.sample
复制到thefile
如果thefile
不存在。这样任何人都可以更新示例文件,但他们不会提交本地更改(例如他们的个人数据库连接字符串)。Mercurial doesn't support this. The correct way to do it is to commit
thefile.sample
and then have your developers (or better you deploy script) do a copy fromthefile.sample
tothefile
ifthefile
doesn't exist. That way anyone can update the example file, but there's no risk of them committing their local changes (say their personal database connect string).啊哈!因此,TortoiseHG 的存储库和全局设置有一个自动排除列表,您可以在其中定义当状态、提交和搁置对话框打开时默认情况下不选中的文件列表。因此它们仍然会出现,但用户必须检查它们才能实际进行提交。该设置存储在 hgrc 中,但它位于 [tortoisehg] 标题下,因此 Mercurial 本身不支持它。尽管如此,它还是符合我的需求。
Aha! So TortoiseHG's repository and global settings have an Auto Exclude List where you can define a list of files that will be unchecked by default when the status, commit, and shelve dialogs open. So they still show up, but the user has to check them in order to actually do a commit. The setting is stored in hgrc, but it's under the [tortoisehg] heading so it's not supported by mercurial per se. Nevertheless, it fits my needs.
对此的一种解决方案是使用嵌套树支持(git 中的子模块),其中“垃圾”将被放入不同的存储库中(以避免主存储库混乱),同时能够以一致的方式检出整个内容(两个存储库的正确版本同步)。
https://www.mercurial-scm.org/wiki/ Subrepository?action=show&redirect=subrepos
在 git 中,子模块是这个问题的一种解决方案 - 但它们在 UI 方面并不是那么好。相反,我所做的是保留两个完全独立的存储库,并在需要使用垃圾存储库更新主存储库时使用子树合并策略: http://progit.org/book/ch6-7.html
One solution to this is to use nested tree support (submodule in git), where the "junk" would be put in a different repository (to avoid cluttering the main repo), while enabling checking out the whole thing out in a consistent manner (right version of both repos in sync).
https://www.mercurial-scm.org/wiki/Subrepository?action=show&redirect=subrepos
In git, submodules are one solution to this issue - but they are not that great UI-wise. What I do instead is to keep two completely independent repositories, and using the subtree merge strategy when I need to update the main repo with the junk repo: http://progit.org/book/ch6-7.html