23

In my mercurial.ini file, I call a global hgignore file like this:

[ui]
ignore = ~/hgignore.ini

This refers to a hgignore.ini file which is in the same directory as the mercurial.ini file.

  1. Does the local hgignore override the global hgignore?
  2. If so, is it recommended to have a single global hgignore with relevant sections marked or have a global hgignore file for general patterns and individual local hgignore files for special patterns pertaining to the particular repo?

By global hgignore with relevant sections marked, I mean:

syntax: glob

# VISUAL STUDIO

*.obj
*.pdb
*.suo
[Bb]in
[Dd]ebug*/
[Rr]elease*/

# TEMPORARY FILES

*.log
*.bak
*.cache    
Animesh
  • 4,926
  • 14
  • 68
  • 110
  • 2
    For those of us that are hard of thinking, `hgignore.ini` is the Windows name; on other OSes this must be `~/.hgrc`. – FauxFaux Dec 14 '13 at 15:06
  • 1
    @FauxFaux: Wrong! It corresponds to `~/.hgignore` on Unix systems. – Noldorin Feb 18 '15 at 01:35
  • 1
    The per-user *Mercurial config file* is `%USERPROFILE%/mercurial.ini` on Windows and `~/.hgrc` on Linux/Unix (though `%USERPROFILE%/.hgrc` is also allowed on Windows). This is detailed in `hg help hgrc`. The *global ignore file* can of course be called whatever you want, since the path is explicitly specified in the config file. – Søren Løvborg Sep 10 '15 at 07:43

1 Answers1

20

The global .hgignore is "added" to the local one. This means that everything in the global one will be considered for each repository, but the content of the local one will also be considered.

For the second question, I think the best answer is : it depends on what you want ;)

  1. If you want a really fine grained control on what is ignored for each repository, go for the local version.
  2. If you want to don't be bothered each time you create a repo, add everything to the global file.
  3. Anything in between to suits your needs...

In my case, I use both of them. The global .hgignore contains project files (Visual Studio, Netbeans), backup files (.bak, vim), libraries (dll, so, etc). And for each project, I put whatever is specific in the local file.

krtek
  • 26,334
  • 5
  • 56
  • 84
  • 3
    I wouldn't recommend ignoring Visual Studio project files unless you are just using it as an editor. The project file contains important information needed to compile the application and will be needed by anyone who clones your repository. If they have to create it themselves then they could create it with different settings and get a different output. – Steve Kaye Nov 29 '11 at 09:05
  • 3
    I include the project files, but exclude the solutions and the suo files – Deanna Nov 29 '11 at 21:34