2010-09-09 10 views
7

Sto cercando di aggiungere alcuni pattern al mio file .gitignore per ignorare i file * .mode1v3 e * .pbxuser generati da Xcode. Tuttavia, il nome della mia app ha uno spazio al suo interno, quindi i file che voglio ignorare sono nella directory Foo Bar.xcodeproj/. L'aggiunta di varianti di questi motivi non sembra funzionare:git ignore per le directory con spazi su Mac OS X

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

Quali dovrebbero essere i modelli .gitignore?

risposta

3

Gli spazi AFAIK non sono trattati in modo speciale; né Pro Git né gitignore(5)fnmatch(3) vengono citati. Ad ogni modo il primo pattern *.mode1v3 è totalmente sufficiente; i modelli senza barre vengono applicati a tutte le sottodirectory. Se si desidera ignorare ulteriori picchietti per una sottodirectory specifica, è sufficiente posizionare uno .gitignore dedicato in tale directory.

+0

Hai ragione. Ho avuto un nuovo momento in cui mi aspettavo che i file commessi venissero ignorati semplicemente in virtù del fatto di essere in .gitignore. Dal momento che sono già registrati, non è questo il caso. Questo lo ha chiarito: http://www.gitready.com/beginner/2009/03/06/ignoring-doesnt-remove-a-file.html – pmc255

2

Hai provato a sfuggire gli spazi nella cartella o i nomi di file con barre rovesciate?

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

Inoltre, questi file sono già stati tracciati da git? Da 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. 

Inoltre, qui sono alcuni dei modelli discussi 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".