2010-09-09 4 views
7

Ich versuche, einige Muster zu meiner .gitignore Datei hinzufügen, um * .mode1v3 und * .pbxuser Dateien zu ignorieren, die von Xcode generiert wurden. Der Name meiner Anwendung enthält jedoch Leerzeichen. Die Dateien, die ich ignorieren möchte, befinden sich daher im Verzeichnis Foo Bar.xcodeproj/. Hinzufügen von Varianten dieser Muster scheint nicht zu funktionieren:Git ignorieren für Verzeichnisse mit Leerzeichen auf Mac OS X

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

Was sollten die .gitignore Muster sein?

Antwort

3

AFAIK-Räume werden nicht speziell behandelt; weder Pro Git noch gitignore(5) noch fnmatch(3) erwähnt sie. Jedenfalls ist das erste Muster *.mode1v3 völlig ausreichend; Muster ohne Schrägstriche werden auf alle Unterverzeichnisse angewendet. Wenn Sie zusätzliche Ignoriermuster für ein bestimmtes Unterverzeichnis wünschen, platzieren Sie einfach ein dediziertes .gitignore in diesem Verzeichnis.

+0

Du hast Recht. Ich hatte einen Anfängermoment, in dem ich erwartete, dass beglaubigte Dateien ignoriert wurden, einfach weil ich in .gitignore war. Da sie bereits eingecheckt sind, ist das nicht der Fall. Das hat es für mich geklärt: http://www.gitready.com/beginner/2009/03/06/ignoring-doesnt-remove-a-file.html – pmc255

2

Haben Sie versucht, irgendwelche Leerzeichen im Ordner oder Dateinamen mit Backslashes zu entkommen?

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

Werden diese Dateien auch bereits von git verfolgt? Von 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. 

Zusätzlich sind hier einige der in man gitignore diskutiert Muster:

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".