gpt4 book ai didi

git - 嵌入 Git 存储库的警告,即使我使用的是子模块

转载 作者:行者123 更新时间:2023-12-05 07:29:04 25 4
gpt4 key购买 nike

我正在尝试了解 Git 子模块的工作原理。我在线阅读了很多文档并设法将子模块添加到我的项目中。这似乎可行,但出于某种原因,我不断在终端中收到此警告:

warning: adding embedded git repository: web/modules/custom/svds_adminmenu
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add <url> web/modules/custom/svds_adminmenu
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached web/modules/custom/svds_adminmenu
hint:
hint: See "git help submodule" for more information.

我觉得这很奇怪,因为 svds_adminmenu 存储库是我添加为子模块的存储库。那么为什么它仍然给我这个警告。

我做了以下工作:

git clone path/repo.git 

然后我用了下面的

git submodules update --init

当我更改 .gitignore 文件并执行以下操作时,我在终端中收到此警告:

git rm -r --cached
git add --all
git commit -m '.gitignore changed'

出了什么问题?

最佳答案

这通常出现在没有 checkout 提交的嵌套 Git 存储库(未出生的分支,或没有任何提交的新创建)

Git 2.22(2019 年第 2 季度)将更明确地说明这种情况:

参见 commit f937bc2 , commit b228270 , commit e138111 (2019 年 4 月 9 日)Kyle Meyer (kyleam) .
(由 Junio C Hamano -- gitster -- merge 于 commit 4ab701b,2019 年 5 月 8 日)

add: error appropriately on repository with no commits

The previous commit made 'git add' abort when given a repository that doesn't have a commit checked out.
However, the output upon failure isn't appropriate:

% git add repo
warning: adding embedded git repository: repo
hint: You've added another git repository inside your current repository.
hint: [...]
error: unable to index file 'repo/'
fatal: adding files failed

The hint doesn't apply in this case, and the error message doesn't tell the user why 'repo' couldn't be added to the index.

Provide better output by teaching add_to_index() to error when given a git directory where HEAD can't be resolved.
To avoid the embedded repository warning and hint, call check_embedded_repo() only after add_file_to_index() succeeds because, in general, its output doesn't make sense if adding to the index fails.

您现在将看到:

'<nested repo folder' does not have a commit checked out
fatal: adding files failed

关于git - 嵌入 Git 存储库的警告,即使我使用的是子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52930569/

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