What’s the difference between adding bin, bin/, bin/* and bin/** in my .gitignore file? I’ve been using bin/, but looking at other .gitignore files (in the eclipse file the double and single star are even used together like this: tmp/**/* what’s up with that?) I see that the first two patterns are also widely used as well. Can someone please explain the differences between the three?
What’s the difference between adding bin , bin/ , bin/* and bin/** in my
Share
binmatches any files or directories named ‘bin’.bin/matches any directories named ‘bin’, which in effect means all of its contents since Git doesn’t track directories alone.bin/*matches all files and directories directly in anybin/. This prevents Git automatically finding any files in its subdirectories, but if, say abin/foosubdirectory is created, this rule will not matchfoo‘s contents.bin/**matches all files and directories in anybin/directory and all of its subdirectories.The word “any” is critical here since rules are not relative to the repository root and apply anywhere in the filesystem tree. You must begin rules with a
/(or!/to un-ignore) which means the repository’s root, not the system’s root, in order to match only what was intended.WARNING: You should never use rules like
dir/*,/dir/**, etc. alone unless you also un-ignore something that exists inside that directory. Omit the asterisk or you could permanently lose a lot of data from certain invocations ofgit gc,git stashand more.I don’t really know what
tmp/**/*is meant to do. I initially thought it could be used to match files in the sub-directories oftmp/but not files directly present intmp/itself. But a simple test seems to suggest that this ignores all files intmp/.