Mercurial——指定某些文件应该总是拉取但从不推送?

发布于 2024-11-15 10:57:13 字数 104 浏览 1 评论 0原文

我希望能够在我的存储库中本地编辑某些文件。但我从来不想将对这些文件的任何更改推送到服务器。我可以这样设置吗?

编辑:澄清一下,我确实想撤回其他人所做的更改。但我不想推动我的改变。

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 技术交流群。

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

发布评论

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

评论(3

枕花眠 2024-11-22 10:57:13

这并不容易实现。 Mercurial 不会推送和拉取文件,而是推送和拉取变更集。您唯一的途径是永远不要提交这些文件。忽略它们不是一个选项,因为它们已经被跟踪(添加)并且跟踪总是覆盖被忽略。

您可以在提交时明确排除它们,例如。

hg commit -X a-file-I-changed -X another-file 

因为您最终会忘记这样做,所以您可以在 hgrc 中设置一个别名:

[alias]
mycommit = -X a-file-I-changed -X another-file 

但是,我会冒险猜测您正在谈论一个配置文件,例如数据库设置文件。处理这个问题的最佳方法是不提交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.

hg commit -X a-file-I-changed -X another-file 

And since you'll eventually forget to do that you could set up an alias in your hgrc:

[alias]
mycommit = -X a-file-I-changed -X another-file 

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 instead database.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.

旧梦荧光笔 2024-11-22 10:57:13

如果您的更改很大,请考虑将其作为 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 then push 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.

岛徒 2024-11-22 10:57:13

Ry4an 写道,您可以在提交时排除该文件。我的一位同事做了一个简单的扩展,可以在简单的情况下自动执行此操作:

https://www.mercurial-scm.org/wiki/ExcludeExtension

https://bitbucket.org/aragost/exclude/

非简单的情况是合并——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:

https://www.mercurial-scm.org/wiki/ExcludeExtension

https://bitbucket.org/aragost/exclude/

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!

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