42

I'm just starting to use hg-git to push some mercurial repositories to github, and I'm realizing that if people check them out using git, they'll need a .gitignore file in the repository. Is there any automated way to convert hgignore to gitignore or vice versa?

Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159

1 Answers1

30

If you're just using glob syntax in your hgignore, then all you'd need to do is rename it, and it should just work. If you're using regex syntax then it's going to be a different story...

Skilldrick
  • 69,215
  • 34
  • 177
  • 229
  • 7
    What about the line at the top saying "syntax: glob"? – Ryan C. Thompson Dec 04 '10 at 10:26
  • 5
    It'll match a file called `syntax: glob`, which, presumably, you won't have :) – Skilldrick Dec 04 '10 at 10:52
  • 2
    That's *not true*, at least with _git version 1.8.3.4_ it does not work for every valid .hgignore expression. – Alex Aug 21 '13 at 08:28
  • @AlexanderOrlov - can you elaborate on which ones don't work or provide a link? I'm just trying to use a hgignore formatted file in git now. – Robbie Aug 22 '13 at 13:48
  • @Robbie Globs like /coffee/**/*.js don't work in hg. – dlitz May 06 '14 at 05:50
  • hg help patterns says ** should work: The supported glob syntax extensions are "**" to match any string across path separators and "{a,b}" to mean "a or b". ... may depend on your hg version. – Cheetah Aug 30 '14 at 04:19
  • This .hgignore, although it has `syntax: glob` at the top, uses stuff like `^web/locale.*` (looks like a reg.exp to me), `glob:*Thumbs.db` (pretty sure that won't work with git), – Carlo Wood May 20 '19 at 16:24