If, and only if, this repository hasn't escaped into the wild, you can remove a file from history by essentially cloning to a new repository while filtering the sensitive file in the process, using hg convert Hg Convert Extension doc here
Commonly, we find something when we audit the repository prior to publishing or delivering to a client, such as a web.config or ini file with a password.
The extension isn't enabled by default, but is included with all clients I use, you need to enable it before Mercurial will recognize the convert command.
If using Tortoise Hg or Kiln, for example:
- Open Tortoise Hg -> Global Settings -> Extensions
- Check the box beside "Convert"
- Click Ok
Or edit Mercurial.ini directly:
[extensions]
convert =
Go to the directory above your repository (in my example, my repos is HelloApp):
Create a file named filemap.txt
Add a line with the full path to the filename you want to exclude.
exclude HelloApp/sensitive.config
Open a command prompt, cd to the same directory, containing your filemap.txt, and run the hg convert
cd C:\projects
hg convert --filemap filemap.txt HelloApp HelloApp_clean
Then get latest working copy:
cd HelloApp_clean
hg update
You will need to create a fresh clone on your server with your clean copy.