Try this as soon as you add all the necessary files:
hg stat --unknown --no-status >> .hgignore
You can create a command to automatically create .hgignore
with alias . On a Unix-like system, add the following lines to .hg/hgrc
(or one of the Mercurial other configuration files ):
[alias] ignore = !echo 'syntax: glob' >> $(hg root)/.hgignore && \ $HG status --unknown --no-status >> $(hg root)/.hgignore
This will give you the hg ignore
command, which will populate the .hgignore
file with all currently unknown files, thereby turning them into ignored ones.
On Windows, the syntax for an alias is:
[alias] ignore = !echo syntax: glob > .hgignore && "%HG%" status --unknown --no-status -X .hgignore >> .hgignore
On Windows, you must run it in the root directory of the repository, otherwise the .hgignore file will be created in the current directory, which is probably not the way you want.
Syntax !
in aliases is new in Mercurial 1.7. In earlier versions you can add
[alias] ignore = status --unknown --no-status
and then redirect the output of this command to the .hgignore
file yourself:
hg ignore >> .hgignore
Then you also need to take care of adding the syntax: glob
line if necessary (the default syntax is regular expressions).
source share