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屋!