git ignore для каталогов с пробелами в Mac OS X - PullRequest
7 голосов
/ 09 сентября 2010

Я пытаюсь добавить некоторые шаблоны в мой файл .gitignore, чтобы игнорировать файлы * .mode1v3 и * .pbxuser, сгенерированные Xcode.Однако в имени моего приложения есть пробел, поэтому файлы, которые я хочу игнорировать, находятся в каталоге Foo Bar.xcodeproj/.Добавление вариантов этих шаблонов, похоже, не работает:

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

Какими должны быть шаблоны .gitignore?

Ответы [ 2 ]

3 голосов
/ 09 сентября 2010

AFAIK пространства не обрабатываются специально;ни Pro Git, ни gitignore(5), ни fnmatch(3) не упоминают их.В любом случае, первая модель *.mode1v3 вполне достаточна;шаблоны без косой черты применяются ко всем подкаталогам.Если вам нужны дополнительные шаблоны игнорирования для определенного подкаталога, просто поместите выделенный .gitignore в этот каталог.

2 голосов
/ 09 сентября 2010

Вы пытались экранировать пробелы в именах папок или файлов с обратной косой чертой?

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

Кроме того, эти файлы уже отслеживаются git? От 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.

Кроме того, вот некоторые из шаблонов, обсуждаемых в 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".
...