0

I have a pretty large folder (with many sub folders) on a mercurial repository. I was a bit too fast with my first commit so I added a lot of files that i now realize shouldn't be on version control. I've updated my .hgignore file accordingly but all the old files are still version controlled. Is there a command that I can write in the root directory that forgets all files that are in a folder of a specific name. These folder names exist in a lot of places and i want them all forgotten with one command since it would take a long time to go through them all manually and forget the folders/files

I guess it would maybe look something like this:

hg ignore ../folderName/

Jesper Evertsson
  • 613
  • 9
  • 28
  • Please note that if you have shared this repo with others, when they `hg update` to the chageset where you `hg forgot` those files, those files will be **deleted** on their machine! (see [here](http://stackoverflow.com/a/9930217) for how `forget` relates to `remove`) – Edward Oct 02 '15 at 15:25

2 Answers2

1

Yes... use a pattern to match them like

hg forget FOLDERNAME**
hg commit -m "Forget FOLDERNAME"

hg help forget
hg forget [OPTION]... FILE...
(...)
options ([+] can be repeated):
 -I --include PATTERN [+] include names matching the given patterns

or use a one-line script:

for i in $(hg ma | grep FOLDERNAME); do hg forget $i; done
planetmaker
  • 5,884
  • 3
  • 28
  • 37
1

You can read hg help filesets and use one of it's samples

  • Forget files that are in .hgignore but are already tracked:

    hg forget "set:hgignore() and not ignored()"

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110