DrJunior
DrJunior

Reputation: 3

Mercurial how to ignore subfolder containing files already added to source control

I have a project with following structure

project_dir/
  WebContent/
    es5/
    ...
  src/ 
  ...
  .hgignore  

I'm tring to ignore everithing under WebContent/es5 directory using following patterns:

syntax: glob
WebContent/es5/**

or

syntax: regexp
^WebContent/es5

or

syntax: regexp
^WebContent/es5$

but modified files in the folder are still being tracked. Could anybody please help me with it?

Upvotes: 0

Views: 286

Answers (1)

Diab Jerius
Diab Jerius

Reputation: 2320

The clue is in the documentation for ignore files:

The Mercurial system uses a file called .hgignore in the root directory of a repository to control its behavior when it searches for files that it is not currently tracking.

If you've added a file in a subdirectory to the repo (either explicitly or before you added the pattern to the .hgignore file) mercurial will remember it until you hg forget it.

% hg init foo

% cd foo

% ls

% mkdir sub

% cat <<EOF > .hgignore
^sub/
EOF

% touch a

% touch sub/b sub/c

% hg st
? .hgignore
? a

% hg add sub/b

% hg st
A sub/b
? .hgignore
? a

% hg forget sub
removing sub/b

% hg st
? .hgignore
? a

There's an example given in the documentation on how to forget all files which are excluded by .hgignore:

   - forget files that would be excluded by .hgignore:

        hg forget "set:hgignore()"

Upvotes: 2

Related Questions