Local Mercurial Ignore File

There are several cases here, so depending on the case you'll have different possible solutions:

  1. If the file or directory hasn't been added yet and if there is no .hgignore file, you can:
    • use .hgignore to filter it, and
    • you can commit .hgignore if this is also useful for others (e.g., *.o, etc.) or you can leave the .hgignore as local without commiting/pushing it, and in this case, you can even specify .hgignore in .hgignore as mentioned by msw so that your local version will also be ignored.
  2. If the file or directory hasn't been added yet and if there is an .hgignore file that for some reason you do not want to use (commit and push), you can:
    • declare an untracked ignore file which you will use just like .hgignore except it will stay local. You can declare this untracked ignore file either in your repo .hg/hgrc or you global $HOME/.hgrc (see the UI section doc).
  3. Finally, if the file/directory has been added to the list of tracked files, then you can't filter it with .hgignore: any file that is already committed cannot be ignored! You can either:
    • "hg forget" the file (the opposite of "hg add"), then do as the two first cases, or use the "-X" option as a default for status/diff/commit in your .hg/hgrc configuration file, e.g.,
      [defaults]
      status = -X file1 -X file2
      diff = -X file -X file2
      commit = -X file -X file3
      which will tell hg not to include these files in the use of status, diff, and commit.

Hope it'll help.


Yes you can configure a local, per-user ignore file. The location and name of this file is defined in the user-specific .hgrc configuration file (usually located in the home directory of the user) under the [ui] section, e.g.:

[ui]
ignore = ~/.myhgignore

This file should be in the same format as the repository-wide .hgignore file.

Reference: http://www.selenic.com/mercurial/hgrc.5.html#ui

Tags:

Mercurial