mismas
mismas

Reputation: 1316

How to ignore folder in mercurial

I have following project strucure:

projectA build/ projectB build/ build
I would like to ignore everything which is under build folder.
I used following in the .hgignore file:

syntax: glob
build/**

It ignores build folder under projectA and projectB, but it doesn't ignore build folder in the root.
How can I accomplish the build folder in the root to also be ignored?

Best regards,
mismas

Upvotes: 2

Views: 2010

Answers (3)

mismas
mismas

Reputation: 1316

This is how my file looks like in the end:

ProjectA/dist
.*\.log
.*\.class
build/
^\.gradle/
^\.settings

I needed to restart Eclipse in order for this to work.
@Nanhydrin thanks for your help :)

Upvotes: 0

rfkortekaas
rfkortekaas

Reputation: 6494

Are the not files already added in that folder? Then you need to run hg forget on those files. Changes afterwards on .hgignore are only applied for newly added files!

Upvotes: 0

Nanhydrin
Nanhydrin

Reputation: 4472

The glob syntax in Mercurial does not operate from the root folder, as you've found it'll match the path wherever in the tree it occurs.
To match relative to the root you'll need to use the regexp syntax, so try:

syntax: regexp
^build/

or

syntax: regexp
^build$

And you can have both regexp and glob syntax in your hgignore file, you just lay it out as follows:

syntax: glob
*.pyc

syntax: regexp
^static/

syntax: glob
*~

Originally from here

Upvotes: 4

Related Questions