Can't stage folder for commit with git add . or git add -u

不想你离开。 提交于 2021-02-15 00:50:16

问题


so if I do a git status I get:

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")

I then tried using git add . and git add -u but I still get the same thing when i use git status. What is going on and how to I push this folder to github? On my github repo the folder bsg-services is showing up as a greyed out folder. What does this mean? Thanks!


回答1:


It (bsg-services) is a submodule. (see "What is this grey git icon?")

You need to:

  • add/commit by going in that folder first (and push from that sub repo),
    (a git status inside bsg-services will tell you more)
  • then go back to the parent repo (where you are), add, commit and push.
    The commit you will have done inside bsg-services will have modified the gitlink entry in the index of your parent repo.

So you need both pushes:

  • one from the submodule repo to its upstream repo (a git remote -v should show you that)
  • one from the parent repo in order to record the new gitlink SHA1 which memorizes the new state of that submodule.



回答2:


I had same problem.

Goto bsg-services subdirectory and make a commit. Thats It!

What happened was you had another git repository inside the bsg-services directory. If u need to get rid of that remove .git directory from bsg-services sub-directory.



来源:https://stackoverflow.com/questions/24167676/cant-stage-folder-for-commit-with-git-add-or-git-add-u

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!