【问题标题】:git won't 'add' subdirgit不会“添加”子目录
【发布时间】:2012-06-20 14:15:21
【问题描述】:

OSX 上的 git 看到修改后的子目录,但不会“添加”它;我怎样才能解决这个问题?谢谢! (我不相信该子目录中有任何打开的文件)

~/gitrepo/python: git status
# On branch br1
# 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:   v0/mage-Upload (modified content)
#
no changes added to commit (use "git add" and/or "git commit -a")
~/gitrepo/python: git add v0
~/gitrepo/python: git add v0/mage-Upload    <-- I guess that was unnecessary
~/gitrepo/python: git diff
diff --git a/v0/mage-Upload b/v0/mage-Upload
--- a/v0/mage-Upload
+++ b/v0/mage-Upload
@@ -1 +1 @@
-Subproject commit 7c377092f1f5cbbeecc03ebb533259c23606506e
+Subproject commit 7c377092f1f5cbbeecc03ebb533259c23606506e-dirty
~/gitrepo/python: git commit -a
# On branch br1
# 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:   v0/mage-Upload (modified content)
#
no changes added to commit (use "git add" and/or "git commit -a")

【问题讨论】:

  • 它说commit or discard the untracked or modified content in submodules ...您正在使用子模块。

标签: git


【解决方案1】:

尝试将其从缓存中删除,然后重新添加

git rm --cached v0
git add v0

【讨论】:

  • 我可以吹走 .git/ 并重新初始化本地 repo 吗?
  • 我不确定你是如何设置项目的,但根据我在 git 删除内容并尝试重新开始的经验,通常会在其他地方更让人头疼(除非这一切都来自淀粉) .
  • 好的,感谢您的 cmets。顺便说一句:我应该如何“关闭”/终止这个 SO 问题?
  • 我不相信我们中的任何一个都有足够的分数来做到这一点。我只是让它打开。有人可能仍然会提出更好的答案。
  • 我看到子目录中有一个神秘的.git/;看起来可能是重复的:stackoverflow.com/questions/5186371/…
【解决方案2】:

您显然在“v0/mage-Upload”中有一个子模块 - 您需要在“超级模块”中的更改之前处理子模块中的更改。执行以下操作:

cd vo/mage-Upload
git status
git commit    # Careful if the submodule is not on a branch
              #   see 'git submodule' documentation
git push ...  # Specific to your submodule

此时您可以返回“超级模块”并将更改提交到子模块引用。

【讨论】:

    【解决方案3】:

    mage-Upload 是一个 Git 子模块。您应该执行以下操作:

    cd vo/mage-Upload
    git commit -a (or whatever you want to commit)
    cd ../..
    git commit -a
    

    这将提交子模块中的任何更改,然后将新的子模块版本提交到主存储库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-15
      • 1970-01-01
      • 2015-04-14
      • 1970-01-01
      • 2015-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多