2010-09-09 12 views
7

Próbuję dodać pewne wzorce do mojego pliku .gitignore, aby ignorować pliki * .mode1v3 i * .pbxuser generowane przez Xcode. Jednak moja nazwa aplikacji zawiera spację, dlatego pliki, które chcę zignorować, znajdują się w katalogu Foo Bar.xcodeproj/. Dodanie wariantów tych wzorców nie działa:git ignore dla katalogów ze spacjami w systemie Mac OS X

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

Jakie powinny być wzorce .gitignore?

Odpowiedz

3

Miejsca AFAIK nie są traktowane specjalnie; ani Pro Git ani gitignore(5) ani fnmatch(3) nie wspominają o nich. W każdym razie pierwszy wzorzec jest całkowicie wystarczający; wzory bez ukośników są stosowane do wszystkich podkatalogów. Jeśli potrzebujesz dodatkowych szablonów ignorujących dla określonego podkatalogu, po prostu umieść w tym katalogu dedykowany .gitignore.

+0

Masz rację. Miałem moment początkujący, w którym spodziewałem się, że pliki zignorowane zostaną zignorowane po prostu na mocy bycia w .gitignore. Ponieważ są już zameldowane, tak nie jest. To wyjaśniło to dla mnie: http://www.gitready.com/beginner/2009/03/06/ignoring-doesnt-remove-a-file.html – pmc255

2

Czy próbowałeś usunąć wszystkie spacje w nazwach folderów lub plików z odwróconymi ukośnikami?

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

Czy te pliki są już śledzone przez git? Od 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. 

Dodatkowo, oto niektóre z omówionych wzorów w 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". 
Powiązane problemy