Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Version control hg添加整个目录,尽管在.hgignore中列出_Version Control_Mercurial_Dvcs_Hgignore - Fatal编程技术网

Version control hg添加整个目录,尽管在.hgignore中列出

Version control hg添加整个目录,尽管在.hgignore中列出,version-control,mercurial,dvcs,hgignore,Version Control,Mercurial,Dvcs,Hgignore,我的mercurial存储库中有两个分支具有相同的.hgignore文件:dir/ 一个分支(开发)应该忽略这个目录,而另一个分支(发布)不应该忽略它。我知道我可以使用hg add dir/somefile,尽管.hgignore文件中有条目。但是现在我想直接递归地添加整个 我搜索了一下,试了试 hg add dir # does not add anything hg add dir* # does not add anything hg add dir/ # does not

我的mercurial存储库中有两个分支具有相同的.hgignore文件:
dir/

一个分支(开发)应该忽略这个目录,而另一个分支(发布)不应该忽略它。我知道我可以使用
hg add dir/somefile
,尽管.hgignore文件中有条目。但是现在我想直接递归地添加整个

我搜索了一下,试了试

hg add dir    # does not add anything
hg add dir*   # does not add anything
hg add dir/   # does not add anything
hg add dir/*  # only adds the files in dir but not in sub-directories
hg add dir/** # only adds the files in dir but not in sub-directories
但这并不是递归的。我可以使用
adddir/*dir/*/*dir/*/*/*
等等,但这很烦人。是否有另一个通配符,我必须使用,或者可能是另一种方式来实现这一点


PS:我希望避免更改.hgignore。

不幸的是,
.hgignore
将忽略任何不是文件完整路径的内容,即使在评估模式时也会受到尊重。其中包含您可以使用的备选方案(假设您不想更改
.hgignore

同时,我能够想出一个解决方案:

hg add --dry-run --verbose `hg status --ignored --no-status --exclude **.DS_Store dir/`
这将显示要添加的文件列表。如果确实要添加它们,请使用以下命令:

hg add `hg status --ignored --no-status --exclude **.DS_Store dir/`

希望这对某人有所帮助。

如果您可以访问
查找
,您可以执行以下操作:

find docs -exec hg add {} \;
每当使用find运行命令时,首先进行一次试运行总是很好的,因此我通常会首先在命令前面粘贴一个
echo

find docs-exec
echo
hg add{}

如果需要添加足够多的文件,而性能是一个问题,则可以使用
+
而不是
\,将所有匹配的文件名附加到同一命令,而不是对每个文件名运行一次命令。对于
hgadd
来说,这不太可能是一个问题,但对于理解
find
的工作原理非常重要


find docs-exec hg add{}
+

我已经尝试了这些文件集,但无法找到一个有效的解决方案。您可以看看我自己的解决方案,到目前为止它似乎还可以工作。为什么不在本地临时更改
.hgignore
,然后将其还原?您不需要签入。。。