gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 01:10:38 28 4
gpt4 key购买 nike

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

最佳答案

来自 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 设置) .

关于git - 当您在 Git 存储库中运行 `git add .git` 时会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6839781/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com