Can I share an ignore file between mercurial and git?

51 Views Asked by At

I use both mercurial and git for similar types of work, and maintain parallel global ignore files. Now, the basic syntax for the two systems is sufficiently similar that I can almost use the same ignore file for both systems. But not quite.

  • git uses (extended) globs to specify ignore patterns.

  • hg uses either full regular expressions (the default) or extended globs to specify ignore patterns. There is a way to specify which system to use.

So to use the same list of globs for both systems, my hg ignore file needs to include a line declaring that the glob syntax is in effect:

syntax: glob
# Compilation artifacts
*.o

This syntax declaration is not recognized by git (which doesn't need one, since it only accepts the glob syntax). I have tried it out and confirmed that it's treated as just another filename: if I create a file called syntax: glob (with a space in the name), git ignores it. This seems harmless but ugly. So: Is there a way to construct a file of ignore patterns that is valid for both systems, without this little wart?

0

There are 0 best solutions below