Mercurial (hg) 只提交某些文件 [英] Mercurial (hg) commit only certain files
问题描述
我正在尝试使用 Mercurial 仅提交某些文件.由于 hg 在我尝试提交更改时自动添加它想要提交所有文件.但我不希望那样,因为某些文件还没有准备好".
I'm trying to commit only certain files with Mercurial. Because of of hg having auto-add whenever I try to commit a change it wants to commit all files. But I don't want that because certain files are not "ready" yet.
有
hg commit -I thefile.foo
但这仅适用于一个文件.对我来说更好的方法是如果我可以像在 Git 中那样关闭自动添加.这可能吗?
but this is only for one file. The better way for me would be if I can turn off auto-add as in Git. Is this possible?
推荐答案
您可以在命令行上指定文件,正如 tonfa 所写:
You can specify the files on the command line, as tonfa writes:
$ hg commit foo.c foo.h dir/
这很管用,而且我一直都是这样做的.您还可以使用您找到的 --include
标志,您可以像这样多次使用它:
That just works and that's what I do all the time. You can also use the --include
flag that you've found, and you can use it several times like this:
$ hg commit -I foo.c -I "**/*.h"
您甚至可以使用文件集来选择您想要的文件提交:
You can even use a fileset to select the files you want to commit:
$ hg commit "set:size(1k - 1MB) and not binary()"
没有任何设置可以关闭自动添加行为并使 Mercurial 像 Git 那样工作.但是,mq 扩展 可能很有趣.这是一个高级扩展,但它允许你做
There is no setting that will turn off the auto-add behavior and make Mercurial work like Git does. However, the mq extension might be of interest. That's an advanced extension, but it allows you do to
$ hg qnew feature-x # create new patch
$ hg qrefresh -s foo.c # add a file to the current patch
$ hg qrefresh -s bar.c # add another file to the patch
$ hg qfinish -a # convert applied patches to normal changesets
不过,我本人并没有真正将 MQ 用于此目的,因为我认为仅在命令行上指定文件名就足够了.
I don't really use MQ for this purpose myself, though, since I think it's enough to just specify the filenames on the command line.
这篇关于Mercurial (hg) 只提交某些文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!