【问题标题】:Can't stage folder for commit with git add . or git add -u无法使用 git add 暂存文件夹以进行提交。或 git add -u
【发布时间】:2014-08-01 18:59:15
【问题描述】:

所以如果我执行 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 显示为灰色文件夹。这是什么意思?谢谢!

【问题讨论】:

    标签: git github staging


    【解决方案1】:

    它 (bsg-services) 是 submodule。 (见“What is this grey git icon?”)

    你需要:

    • 首先进入该文件夹添加/提交(并从该子存储库推送),
      bsg-services 中的 git 状态会告诉你更多信息)
    • 然后返回父存储库(您所在的位置),添加、提交和推送。
      您将在 bsg-services 中完成的提交将修改您父仓库索引中的 gitlink entry

    所以你需要两个推送:

    • 从子模块存储库到其上游存储库的一个(git remote -v 应该会告诉您)
    • 来自父 repo 的一个,用于记录新的 gitlink SHA1,它可以记住该子模块的新状态。

    【讨论】:

    【解决方案2】:

    我有同样的问题。

    转到 bsg-services 子目录并提交。就是这样!

    发生的事情是您在 bsg-services 目录中有另一个 git 存储库。如果您需要从 bsg-services 子目录中删除该删除 .git 目录。

    【讨论】:

      猜你喜欢
      • 2018-07-09
      • 2011-01-12
      • 2013-07-17
      • 2012-02-27
      • 2017-08-26
      • 2013-02-07
      • 2015-03-19
      • 2021-05-28
      • 1970-01-01
      相关资源
      最近更新 更多