问题
Trying to do something similar to here: Applying .gitignore to committed files
Where you apply the new hgignore file to the already committed files.
I have node_modules folder already committed with thousands of files and I'd like to remove it by using the new hgignore file.
I can't find anything online for it to work on a Mercurial repo, any ideas? Thanks!
回答1:
- Edit
.hgignore
to match files you want to ignore hg forget "set:hgignore()"
and commit
See in action:
- https://asciinema.org/a/kuJERsouDkOUBspADjDM5pMRQ
See also:
- hg remove all files listed in .hgignore
- How to check which files are being ignored because of .hgignore?
回答2:
This is very easy once you get the steps. hgignore does not apply to the files already committed for tracking.
I use Tortoise Hg Workbench for UI.
In case build related binary files are checked in that need not be tracked, try this. When a rebuild is done, those files will again appear under files to commit. You can see this by selecting the green Commit button in the toolbar.
Select the files you want to ignore, then right click and select "Forget" (remember you have already committed the file earlier). This would mark the files as "R" for removal. Select the checkboxes next to the file and commit.
After commit, there would be a “?” mark next to those files and will appear in pink. Select those files and right click and select "Ignore". This would bring up the hgignore editor. Add to .hgignore from that editor.
Commit the .hgignore as well so that you have it safe.
In case you are using this for your personal work, why dont you try VSTS, its really cool, has both git and TFS as the backhaul! I moved all my personal work to VSTS.
Note: Sorry for not being able to upload screen shots, absolutely tight on schedule.. :(
来源:https://stackoverflow.com/questions/45608337/applying-hgignore-file-to-already-committed-file-mercurial-repo