无法使用git add .或git add -u将文件夹暂存以提交

5
所以,如果我执行git status,则会得到以下结果:
bsg-integration> git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

    modified:   bsg-services (untracked content)

no changes added to commit (use "git add" and/or "git commit -a")

我尝试使用git add .git add -u,但是当我使用git status时仍然得到相同的结果。出了什么问题?我该如何将此文件夹推送到github?在我的github仓库中,bsg-services文件夹显示为灰色。这是什么意思?谢谢!

2个回答

7

它(bsg-services)是一个子模块。(参见“这个灰色的git图标是什么?”)

您需要:

  • 首先进入该文件夹进行添加/提交(并从子存储库推送),
    (bsg-services内的git状态将为您提供更多信息)
  • 然后回到父存储库(您所在的位置),添加、提交和推送。
    您在bsg-services内完成的提交将修改您父存储库中索引中的git链接条目

因此,您需要两次推送:

  • 从子模块存储库到其上游存储库(使用git remote -v命令可查看)。
  • 从父存储库推送一次,以记录新的git链接SHA1,该SHA1记忆了该子模块的新状态。

注意:要删除子模块:https://dev59.com/QHM_5IYBdhLWcg3wt1k0#16162000 或 https://dev59.com/q2Ei5IYBdhLWcg3wWLAS#21381862 - VonC

4

我遇到了同样的问题。

进入 bsg-services 子目录并提交即可。就是这样!

问题在于您在 bsg-services 目录中有另一个 git 仓库。如果您需要摆脱它,请从 bsg-services 子目录中删除 .git 目录。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接