Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

hgignore file in Mercurial

📅 2010-Mar-09 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

There might be certain files or kinds of files you might want Mercurial to ignore or not track. For example, the *.obj and *.exe files generated by the Visual C++ compiler. Ignoring such files also reduces the visual clutter or information overload in the output of commands such as hg status.

To tell Mercurial to ignore certain files (say *.obj and *.exe files), create a .hgignore file in the root of your repository and add the following text into it:

#-------------------------------------------------------
# .hgignore: Files that Mercurial should ignore
#-------------------------------------------------------

# Use glob syntax
syntax: glob

# Ignore object files
*.obj

# Ignore executables
*.exe
#-------------------------------------------------------

Note that the .hgignore file needs to be added and committed into the repository as well:

$ hg add .hgignore
$ hg commit