Is it safe to use the same ignores file for Git, Mercurial, and Bazaar?
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
- Refactor during a feature implementation with mercurial
- Mercurial convert extension not able to pull from remote Git repository
- How do I export changesets from hg repository to svn repository
- BitBucket colored diff email service
- Differentiated access rights in distributed VCS's
- How can I synchronize closed and open sourced versions of the same tool using Mercurial?
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?
2 Solutions collect form web for “Is it safe to use the same ignores file for Git, Mercurial, and Bazaar?”
The syntax used in the ignore files is different from system to system:
Mercurial: list of regular expressions — can be changed with a
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:
syntax: glob .bzr .git .hg *.o *~
and it seems to work as intended across all three tools. To test it, I created this directory tree:
$ tree . |-- foo.c |-- foo.c.~1~ |-- foo.h |-- foo.o `-- src |-- bar.c |-- bar.c.~1~ `-- bar.o
and ran the status command for each tool:
$ for tool in hg git bzr; do echo "== $tool status =="; $tool status; done == hg status == ? foo.c ? foo.h ? src/bar.c == git status == # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # foo.c # foo.h # src/ nothing added to commit but untracked files present (use "git add" to track) == bzr status == unknown: foo.c foo.h src/
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 adding
[ui] ignore.my-default = ~/.hgignore
Syntax of at least Git and Mercurial differ (glob and regex patterns in hg), don’t forget also filesets in hg, ! conditions in bzr