2010-09-09 22 views
7

Estoy tratando de agregar algunos patrones a mi archivo .gitignore para ignorar los archivos * .mode1v3 y * .pbxuser generados por Xcode. Sin embargo, el nombre de mi aplicación tiene un espacio, por lo que los archivos que deseo ignorar están en el directorio Foo Bar.xcodeproj/. Agregar variantes de estos patrones no parece funcionar:git ignorar directorios con espacios en Mac OS X

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

¿Qué deberían ser los patrones .gitignore?

Respuesta

3

Los espacios AFAIK no se tratan especialmente; ni Pro Git ni gitignore(5) ni fnmatch(3) los menciona. De todos modos, el primer patrón *.mode1v3 es totalmente suficiente; los patrones sin barras se aplican a todos los subdirectorios. Si desea patrones de ignorar adicionales para un subdirectorio específico, simplemente coloque un .gitignore dedicado en ese directorio.

+0

Tienes razón. Tuve un momento novato donde esperaba que los archivos comprometidos fueran ignorados simplemente por estar en .gitignore. Como ya están registrados, ese no es el caso. Esto lo aclaró para mí: http://www.gitready.com/beginner/2009/03/06/ignoring-doesnt-remove-a-file.html – pmc255

2

¿Ha intentado escapar de los espacios en la carpeta o los nombres de archivo con barras diagonales inversas?

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

Además, ¿estos archivos ya están siendo rastreados por git? De 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. 

Además, aquí están algunos de los patrones discutidos en 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".