Mercurial - How to remove a file from version control?

Greg picture Greg · Jul 14, 2010 · Viewed 30k times · Source

So I accidentally included a config file (different for each machine) into our mercurial repositories.

How can I get Mercurial to not include it in version control? I don't want to delete the file since I still want it. And I don't want to cause the file to get deleted on other developer's working directories either.

And how do I do this in TortoiseHG?

Answer

Nate picture Nate · Jul 14, 2010

Right click on the file -> TortoiseHG -> Forget Files. Click Forget. Commit and Sync.

Edit: You'll also want to add the path to your .hgignore to keep it from getting added again. You can right click on the file in the HG Commit dialog and choose to ignore it.