Scott Mitchell
Scott Mitchell

Reputation: 8759

Why is .hgignore being ignored?

I am very new to Hg so please excuse my ignorance here...

I am using Mercurial and TortoiseHg in Windows 7. I have a repository created that has the following folder structure:

-- My repo dir
|
|--- .hg
|--- .hgignore
|--- File 1
|--- File 2
|--- ...

My database data files live in the repo directory but I do not want them to be included as part of the repository. I've tried all kinds of things in the .hgignore file, but regardless when I right-click on the repo folder in the Windows Shell and go to Hg Commit..., it includes the two database data files in the list of files to be committed. Yes, I can uncheck them manually, but my thought was that by being in .hgignore they wouldn't be included in the list of files to commit.

Here's my current incarnation of .hgignore, although I've tried a handful of others with no luck:

MyDatabase\.mdf
MyDatabase\_log\.ldf

Am I being daft here, or is it that TortoiseHg does not respect/inspect the .hgignore file when committing?

UPDATE:

Finally got this to work. I had to instruct Mercurial to forget the files, as @Diego suggested. Interestingly, though, when I followed @Diego's suggestions and tried to forget them via the command-line it did not work. I had to go to Windows Explorer, right-click on the files, and from the context menu I chose TortoiseHg --> Forget Files...

Thanks for the suggestions, everyone.

Upvotes: 7

Views: 5882

Answers (3)

smooth reggae
smooth reggae

Reputation: 2219

Scott, Do you have any other mdf/ldf files that you want to add to the repository? If not, could you just try the following in your .hgignore file?

syntax: glob
*.mdf
*.ldf

Upvotes: 0

César
César

Reputation: 10119

You need to add this line at the beginning of your .hgignore file:

syntax: glob

MyDatabase\.mdf
MyDatabase\_log\.ldf

Upvotes: 1

Diego
Diego

Reputation: 699

Maybe mercurial is already tracking those files. If files are already tracked then .hgignore does not have any effect. Try:

hg forget MyDatabase\.mdf MyDatabase\_log\.ldf

Then edit .hgignore to exclude those files and commit.

That should solve it.

Upvotes: 11

Related Questions