2011-07-27 28 views

Respuesta

19

Comentario de Git fuente:

/* 
* Read a directory tree. We currently ignore anything but 
* directories, regular files and symlinks. That's because git 
* doesn't handle them at all yet. Maybe that will change some 
* day. 
* 
* Also, we ignore the name ".git" (even if it is not a directory). 
* That likely will not change. 
*/ 

experimento para ver qué sucedió, si se crea un archivo .git y tratar de agregarlo: (en Windows No puedo crear un archivo .git cuando ya hay una carpeta .git. También podría haber creado un .git en otro lugar en un subdirectorio, pero quería probar --git-dir y --work-tree que no he usado antes. Después de todo, estoy experimentando. Esto también me permite mostrar que puedo añadir la carpeta git metadatos como se verá más adelante)

git --git-dir="c:/test" init 
touch blah 
git --git-dir="c:/test" --work-tree="." add . 
git --git-dir="c:/test" --work-tree="." status (shows blah added) 
touch .git 
git --git-dir="c:/test" --work-tree="." add .git (no output as usual) 
git --git-dir="c:/test" --work-tree="." status (only blah shown) 

Así que sí, .git - ya sea de directorio o archivo, es ignorado por git.

Y si hago algo, como a continuación:

git --git-dir="c:/test" --work-tree="c:/test" add c:/test 

se añaden todos los archivos de Meta.

De nuevo, solo se ignora .git, no la carpeta de metadatos git (que se establece a través de --git-dir) hasta donde puedo ver.

+0

¿En qué archivo/revisión en la fuente encontraste este comentario? –

+0

No importa, lo encontré - https://github.com/git/git/blob/fe9122a35213827348c521a16ffd0cf2652c4ac5/dir.c#L1277 –

+0

¿Qué quiere decir con "el directorio de metadatos git"? ¿No es el directorio que configura con '--git-dir' su directorio de trabajo? – HelloGoodbye

16

Respuesta corta: Nada.

Respuesta larga:

laptop:Projects ctcherry$ mkdir test 
laptop:Projects ctcherry$ cd test 
laptop:test ctcherry$ git init . 
Initialized empty Git repository in /Users/ctcherry/Projects/test/.git/ 
laptop:test ctcherry$ git add .git 
laptop:test ctcherry$ git status 
# On branch master 
# 
# Initial commit 
# 
nothing to commit (create/copy files and use "git add" to track) 
laptop:test ctcherry$