30

虽然它似乎什么也没做,但它没有给出警告或错误消息。有任何想法吗?

4

2 回答 2

23

来自 Git 源的评论:

/*
 * 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.
 */

实验看看如果我创建一个文件.git并尝试添加它会发生什么:(在 Windows 上,.git当已经有一个.git文件夹时,我无法创建文件。我也可以.git在子目录的其他地方创建一个,但想--git-dir尝试--work-tree一下我以前没用过。毕竟我是在试验。这也让我表明我可以添加git元数据文件夹,如下所示)

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)

所以是的,.git- 无论是目录还是文件,都会被 git 忽略。

如果我执行以下操作:

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

所有元文件都被添加。

再说一次,据我所知.git,只是忽略了 git 元数据文件夹(您通过 设置)。--git-dir

于 2011-07-27T06:14:24.130 回答
18

简短的回答:什么都没有。

长答案:

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$ 
于 2011-07-27T05:33:44.337 回答