添加一个以前有自己的git存储库的目录

时间:2014-09-04 08:58:53

标签: git git-submodules

我让Git与其他Git项目合作。 我最终决定删除第二个,所以我删除了.git目录:

rm -rf /pathToProject/pathToProjectInsideProject/.git

但现在,当我git status时,我无法在pathToProject/pathToProjectInsideProject/目录中看到更改。

我试过:

git add pathToProjectInsideProject

但没有任何改变。有关如何将此目录包含到主git存储库的任何想法吗?

修改

当我尝试使用forcegit add --force pathToProjectInsideProject/file.php)添加单个文件时,我收到此错误:

  

pathToProjectInsideProject / file.php在submodule pathToProjectInsideProject

EDIT2:

这个问题重复:How do I add files in Git to the path of a former submodule?

解决方案是:

git rm --cached pathToProjectInsideProject
git add pathToProjectInsideProject

1 个答案:

答案 0 :(得分:0)

有一种使用git shell添加文件的交互方式。

git add -i

*** Commands ***
  1: status       2: update       3: revert       4: add untracked
  5: patch        6: diff         7: quit         8: help
What now> 4
  1: New Text Document.txt
  2: s/New Text Document.txt
Add untracked>>

如果数量较少,请添加文件。或者使用git commit工具,它提供交互式UI。

编辑:

*表示该文件已添加到曲目

enter image description here