【问题标题】:Add git folder add not working - getting white arrow添加 git 文件夹添加不起作用 - 得到白色箭头
【发布时间】:2020-12-03 07:26:44
【问题描述】:

我已经阅读了有关 stackoverflow 的其他一些帖子并意识到了这个问题,但是,我该如何解决这个问题?我试过:git rm --cached client_folder 但我收到以下错误消息:我有同样的问题:

Reinitialized existing Git repository in /Users/user/Desktop/final-8/.git/
User@User final-8 % git add client
warning: adding embedded git repository: client
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> client
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:   git rm --cached client
hint: 
hint: See "git help submodule" for more information.

我该如何解决这个问题?我试过了:git rm --cached client_folder 但出现以下错误消息:

git rm --cached client

error: the following file has staged content different from both the
file and the HEAD:
    client
(use -f to force removal)

[编辑] 我跑了git rm --cached -f client 这就是我得到的:

User final-8 % git rm --cached -f client 
**rm 'client'** 
User final-8 % git init 
Reinitialized existing Git repository in /Users//Desktop/final-8/.git/ 
User final-8 % git add client 
warning: adding embedded git repository: client 
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. 

我又试了一次,现在我得到了:

client % git rm --cached -f client
fatal: pathspec 'client' did not match any files

【问题讨论】:

  • client 已经是一个(独立的)Git 存储库。您不能将存储库添加到存储库;如果您要求 Git 这样做,您会收到上述警告,相反,Git 添加了一个 link(所谓的 gitlinkto该存储库,而不是实际添加存储库。这就是你看到的箭头:一个 gitlink。如果您不想要 gitlink,请不要使用(子)存储库:将(子)存储库的所有有用文件 out 复制到 not 的某个位置存储库。
  • 如果你确实想要一个 gitlink,你应该遵循 Git 给出的建议,使用git submodule add,这样 Git 不仅会添加 gitlink 本身,还会添加所有使子模块工作所需的其他东西。
  • @torek 谢谢。我现在才看到这个。那么如何将我的客户端文件夹中的文件推送到 github 呢?
  • 我设法删除了客户端文件夹,并删除了客户端文件夹中的 .gitignore 文件,并将客户端文件夹重新添加到我的本地存储库,然后添加到 github。那行得通。谢谢你的帮助。
  • 很高兴你得到了你想要得到的东西,但请记住:Git 不是关于文件,而是关于提交。提交包含文件(并且,对于子模块,提交也包含一个或多个 gitlink),当您 git push 时,您发送的是 commits 而不是文件。 (当然,提交 包含 文件,所以它们是随心所欲的,但请记住,它始终基于提交。你要么得到一个完整的提交,要么一个都没有。)跨度>

标签: git github git-push


【解决方案1】:

最后一行实际上是在您的git rm 命令上打开-f 选项的指示:

git rm --cached -f client

【讨论】:

  • 在评论中不太可读:您可以将其添加到您的问题正文中吗?
  • 我不明白你编辑的重点?您上一条命令中的提示符为client %,您在运行命令之前是否cd client
  • 是的,cd client 然后 git rm --cached -f client
  • 你那里没有client 项目,是吗?
  • 我的项目文件夹“final-8”中有一个客户项目。还有一个 gitignore 文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-15
  • 2012-10-31
  • 1970-01-01
  • 1970-01-01
  • 2020-09-15
  • 2017-04-04
相关资源
最近更新 更多