Git, Mercurial, and Bazaar all seem to have similar formats for their ignore file (.gitignore
, .hgignore
, .bzrignore
[see also bzr patterns]).
In order to improve synchronization of the global ignore files, would it be safe to use one as an actual file and simply symlink the other two to that file? In other words, is there any danger in making my $HOME/.gitignore
the canonical ignores file and doing
ln -s $HOME/.gitignore $HOME/.hgignore
ln -s $HOME/.gitignore $HOME/.bazaar/ignore
or is there some subtle difference among them that would bite me at some point?
The syntax used in the ignore files is different from system to system:
Mercurial: list of regular expressions — can be changed with a
syntax: glob
line.Bazaar: list of shell glob patterns — prefixing with
RE:
to match as regular expression.Git: list of shell glob patterns.
Furthermore, the exact rules for how the shell patterns and regular expressions are matched differ from tool to tool. All in all, this means that you can only hope to use this trick if your global ignore file is pretty simple. Otherwise the differences can come and bite you, as you say.
I tested it with this file:
and it seems to work as intended across all three tools. To test it, I created this directory tree:
and ran the status command for each tool:
As you can see, this simple file works fine.
Technically, Git and Bazaar will now ignore a file called
syntax: glob
, but unless you plan to create a file with that weird name, this doesn't matter. Finally, note that Mercurial doesn't read a$HOME/.hgignore
file by default. But you can make it read it by addingto your
$HOME/.hgrc
file.Syntax of at least Git and Mercurial differ (glob and regex patterns in hg), don't forget also filesets in hg, ! conditions in bzr