Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
861 views
in Technique[技术] by (71.8m points)

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

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...