Mercurial——指定某些文件应该总是拉取但从不推送?
我希望能够在我的存储库中本地编辑某些文件。但我从来不想将对这些文件的任何更改推送到服务器。我可以这样设置吗?
编辑:澄清一下,我确实想撤回其他人所做的更改。但我不想推动我的改变。
There are certain files in my repository that I want to be able to edit locally. But I never want to push any changes to those files to the server. Is it possible for me to set that up?
EDIT: to clarify, I do want to pull changes that others have made. But I don't want to push my changes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这并不容易实现。 Mercurial 不会推送和拉取文件,而是推送和拉取变更集。您唯一的途径是永远不要提交这些文件。忽略它们不是一个选项,因为它们已经被跟踪(添加)并且跟踪总是覆盖被忽略。
您可以在提交时明确排除它们,例如。
因为您最终会忘记这样做,所以您可以在 hgrc 中设置一个别名:
但是,我会冒险猜测您正在谈论一个配置文件,例如数据库设置文件。处理这个问题的最佳方法是不提交
database.conf
(或任何名称),而是提交database.conf.sample
,然后让您的启动脚本复制database.conf .sample 到database.conf(如果它尚不存在)。这是正常的做法。It's not easily possible. Mercurial doesn't push and pull files it pushes and pulls changesets. Your only route would be to never commit those files. Ignoring them isn't an option because they're already tracked (added) and tracked always overrides ignored.
You could explicitly exclude them on commits like.
And since you'll eventually forget to do that you could set up an alias in your hgrc:
However, I'm going to go out on a limb and guess you're talking about a configuration file like a database settings file. The best way to handle that is to commit not
database.conf
(or whatever it's called) but insteaddatabase.conf.sample
and then have your launch script copy database.conf.sample to database.conf if it doesn't already exist. That's the normal practice.如果您的更改很大,请考虑将其作为 Mercurial Queue 中的补丁。您可以
弹出
您的更改,提取其更改,然后推
您的更改回到工作目录。如果这是一个您无法忍受失去的更改,您可以使队列成为自己的存储库,然后将该存储库克隆到其他地方。If your change is substantial consider making it a patch in a Mercurial Queue. You can
pop
your change, pull their changes, and thenpush
your change back on to the working dir. If it's a change you couldn't bear to lose you can make make the queue a repository of its own, and then clone that repository elsewhere.Ry4an 写道,您可以在提交时排除该文件。我的一位同事做了一个简单的扩展,可以在简单的情况下自动执行此操作:
非简单的情况是合并——Mercurial 不会让您在提交合并时排除文件。目前,您必须将修改后的文件移到一边,恢复它,然后在合并后将其移回。欢迎补丁来处理这种情况!
A Ry4an writes, you can exclude the file when you commit. A colleague of mine has made a simple extension that will automate this in simple cases:
The non-simple case is a merge -- Mercurial wont let you exclude files when you commit a merge. For now, you'll have to move the modified file aside, revert it, and then move it back after the merge. Patches are welcome to handle this case!