Git ignore directories with spaces in Mac OS X

I am trying to add some templates to my .gitignore file to ignore the * .mode1v3 and * .pbxuser files created by Xcode. However, my application name has a space, so the files I want to ignore are in the Foo Bar.xcodeproj/ directory. Adding variations of these patterns does not work:

 *.mode1v3 Foo Bar.xcodeproj/ Foo Bar.xcodeproj/*.mode1v3 Foo Bar.xcodeproj/username.mode1v3 

What should be the .gitignore templates?

+7
git gitignore iphone xcode macos
source share
2 answers

AFAIK spaces are not specially treated; neither Pro Git, nor gitignore(5) , nor fnmatch(3) mention them. In any case, the first *.mode1v3 template is quite sufficient; non-slash patterns apply to all subdirectories. If you want to add additional ignore patches for a specific subdirectory, just put the highlighted .gitignore in this directory.

+3
source share

Have you tried to avoid spaces in a folder or file names with backslashes?

 *.mode1v3 Foo\ Bar.xcodeproj/ Foo\ Bar.xcodeproj/*.mode1v3 Foo\ Bar.xcodeproj/username.mode1v3 

Also, are these files already tracked with git? From man gitignore :

 A gitignore file specifies intentionally untracked files that git should ignore. Note that all the gitignore files really concern only files that are not already tracked by git; in order to ignore uncommitted changes in already tracked files, please refer to the git update-index --assume-unchanged documentation. 

In addition, here are some of the patterns discussed in man gitignore :

 o If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git). o If the pattern does not contain a slash /, git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file). o Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html". o A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". 
+2
source share

All Articles