hg local ignore
Asked Answered
A

2

42

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?

Aurlie answered 15/6, 2009 at 14:54 Comment(0)
A
53

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.)

Aurlie answered 15/6, 2009 at 15:21 Comment(3)
@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.Substandard
@ErikAllik: The link is dead (the page seems to have been blanked or something). Is there some chance you could provide these steps?Pingpingpong
I 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.Goral
B
22

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
Blum answered 13/8, 2015 at 19:5 Comment(3)
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 fileFichu
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.Blum
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!Redundant

© 2022 - 2024 — McMap. All rights reserved.