I could have sworn there was a way to keep a local ignore file in an hg repo, i.e. a file similar in function to .hgignore, but not checked into the repo. This could be used to ignore changes to an IDE project file if different IDEs are being used, for example. I'm having trouble finding how it's done. Does anyone recall the details?
Asked
Active
Viewed 8,374 times
3 Answers
52
This is what I was looking for.
Add the following to the repo's .hg/hgrc:
[ui] ignore = /path/to/repo/.hg/hgignore
and create a new file .hg/hgignore beside it. This new file will be untracked, but work the same as the versioned .hgignore file for this specific working copy. (The /path/to/repo bit is unfortunate but necessary to make it work when invoking 'hg' from within a subdir of the repo.)

Vadim Kotov
- 8,084
- 8
- 48
- 62

fakeleft
- 2,830
- 2
- 30
- 32
-
@Restuta, there's a (hidden) .hg folder in your repository root; create a file in there named 'hgignore' and then edit the hgrc file (in the same hidden .hg folder) as guided at the provided URL. – Erik Kaplun Jun 19 '11 at 19:28
-
@ErikAllik: The link is dead (the page seems to have been blanked or something). Is there some chance you could provide these steps? – Nicol Bolas Sep 02 '13 at 07:48
-
4I am using Mercurial 2.8.1. It seems they have removed this unfortunate `/path/to/repo` requirement (I got an "No such file or directory" error). Use `ignore = .hg/hgignore` works. So it seems now it is defaulted to the root of the repository. – day Jan 29 '14 at 00:22
21
In version 3.5, setting the ignore
property under the ui
section changes the global ignore file. To add additional files to be ignored, follow the advice of Jeroen Dierckx and set the ignore.local
property to get the same effect as adding to .git/info/exclude
in a git
repository.
[ui]
ignore = .hgignore
ignore.local = .hg/hgignore

Keith Prussing
- 803
- 8
- 19
-
i keep getting: "skipping unreadable ignore file '': invalid mode ('r') or filename " no matter what settings i use, atm i have the above in my .hgignore file – IronHide Apr 27 '16 at 20:35
-
Try using the full path to the ignored file. I know I've had to do that in a few projects, but I can't recall if it was for the same reasons. – Keith Prussing Apr 27 '16 at 20:44
-
That "unreadable ignore" message for me was caused by the comments at the end of the line! Works fine without them, fails again when I put them back! – Noumenon Aug 26 '16 at 20:12
2
Just make an .hgignore file and add .hgignore to the .hgignore file itself.

John Weldon
- 39,849
- 11
- 94
- 127
-
1In that case, you could use the .hgignore file for everyone, and a .hgignore.local file which you ignore in .hgignore, but add in .hg/hgrc. Like this: [ui] ignore.local = /path/to/hgignore.local – Jeroen Dierckx Jun 07 '12 at 14:23