Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在git存储库中运行`git add.git`时会发生什么?_Git_Git Add - Fatal编程技术网

在git存储库中运行`git add.git`时会发生什么?

在git存储库中运行`git add.git`时会发生什么?,git,git-add,Git,Git Add,虽然它似乎什么也没做,但它没有给出任何警告或错误消息。有什么想法吗?简短的回答:没有 长答覆: 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

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

简短的回答:没有

长答覆:

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$ 

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
。毕竟我正在尝试。这也让我证明我可以n添加git元数据文件夹(如下所示)

所以是的,
.git
——不管是目录还是文件,都被git忽略了

如果我做了如下的事情:

git --git-dir="c:/test" --work-tree="c:/test" add c:/test
所有的元文件都被添加


因此,在我看来,只有
.git
被忽略,而不是git元数据文件夹(您通过
--git dir
设置的);我承认是我干的。我之所以编辑它,是因为我想添加
.gitignore
,但制表符的完成在
.git
处停止,所以我意外地这样做了。我(和你一样)担心“我破坏了什么?”。我这么做是因为我一直在使用GNU stow将
.git/info/exclude
文件安装到我与其他人共享的存储库中,我想将包含此
.git
文件夹的stow包置于版本控制之下。您在源代码中的哪个文件/版本中找到了此注释?不管怎样,找到了--您所说的“git元数据目录”是什么意思?您用
--git dir
设置的目录不是您的工作目录吗?但是如果您尝试在
.git
目录中添加文件,会发生什么情况?那么名称将不是“.git”。
git --git-dir="c:/test" --work-tree="c:/test" add c:/test