Identical question to gitignore: Ignore all files in folder hierarchy except one specific filetype, but for Mercurial.
I want .hgignore
to ignore all files except one or more files from a specific file type, for instance only allow files of the *.java
and *.class
file type to be tracked, in the current directory as well as sub directories.
For example, in the following directory:
A.java
a.txt
a.png
A.class
B/C.java
B/G/H/h.png
B/C.class
D/E/F.java
I only want the following files to be included (including the structure of the directories):
A.java
A.class
B/C.java
B/C.class
D/E/F.java
(如果含有<代码>h.png<>/code>的目录将制作或不再制作,则无关紧要。)
I ve tried applying and changing the same principles as mentioned in the question above (but for Mercurial instead), as well as trying to apply principles from the question How can I ignore all directories except one using .hgignore?, without any luck.
EDIT:我用上述树种尝试如下:
$ hg stat
? A.class
? A.java
? B/C.class
? B/C.java
? B/G/H/h.png
? D/E/F.java
? a.png
? a.txt
$ hg add -I "**.{class, java}"
adding A.class
adding A.java
adding B/C.class
adding B/C.java
adding D/E/F.java
which gave me the wanted result. How do I create a .hgignore
or config file that applies the -I "**.{class, java}"
for each add
or commit
(and similar queries)?