I want to ignore all files with the pattern d*.cpp
. These file could be in the same directory as .gitignore, or in any sub-directory.
How should that rule look like?
**/d*.cpp
does not do what I think it should.
I want to ignore all files with the pattern d*.cpp
. These file could be in the same directory as .gitignore, or in any sub-directory.
How should that rule look like?
**/d*.cpp
does not do what I think it should.
The pattern looks correct. git
will ignore any d*.cpp
file anywhere in your git repository. However; gitignore works only for untracked files; as written in the documentation:
gitignore - Specifies intentionally untracked files to ignore
If you want to ignore changes to the d*.cpp
files that have already been added to your repository; you can use --skip-worktree
or --assume-unchanged
. You can take a look at this answer for a good explanation of these two concepts. (special thanks to @1615903 for pointing me to skip-worktree)
The **
syntax is not available for .gitignore in early versions of git. The solution is to upgrade to 1.8.2.1 or later.