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
703 views
in Technique[技术] by (71.8m points)

recursion - git add -A is not adding all modified files in directories

I want to add all files no matter what: whether it is deleted, created, modified, untracked, etc? I just don't want to git add ALL my files EVERY TIME. I tried git add -A but it is NOT adding modified files inside folders.

Here is my initial git status in my project:

Rakib-MacBook-Pro:my-xcode-practice rakib$ git status
# On branch 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:   BankAccount (modified content, untracked content)
#   modified:   BuckysButtons (modified content, untracked content)
#   modified:   multiview (modified content, untracked content)
#   modified:   rotator (modified content, untracked content)
#   modified:   segmentedControls (modified content, untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")

Then I put git add -A:

Rakib-MacBook-Pro:my-xcode-practice rakib$ git add -A

and then here is the new status AFTER doing git add -A:

Rakib-MacBook-Pro:my-xcode-practice rakib$ git status
# On branch 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:   BankAccount (modified content, untracked content)
#   modified:   BuckysButtons (modified content, untracked content)
#   modified:   multiview (modified content, untracked content)
#   modified:   rotator (modified content, untracked content)
#   modified:   segmentedControls (modified content, untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")

You can see that there has been no change in the git status. How do I solve this?

I also tried git add . - it did not help

I also tried git add * - it did not help

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

The problem here is that BankAccount, BuckysButtons, multiview, rotator and segmentedControls are all git submodules, which act like independent repositories in many ways.

If what you want to do is to run git add -A . in each submodule, you could do:

git submodule foreach --recursive git add -A .

And then you could create a commit in every submodule with:

git submodule foreach --recursive "git commit -m 'Committing in a submodule'"

(If you don't have other submodules nested inside those submodules, the --recursive option is unnecessary.)

However, I don't recommend doing this. You should carefully change into each submodule in turn, and consider how you want to update them, treating each as a standalone repository. Then only commit these new submodule versions in the main project when you have tested that the project as a whole works with those new versions of each submodule.


Update: It seems from the error message that you've quoted in the comments below that you have added these other git repositories directly rather than as submodules. This can happen if you copy another git repository into your repository and then just use git add to stage it, rather than adding it with git submodule add <REPOSITORY-URL>. If you really intend these to be stored as submodules, I would suggest moving them out of your repository, committing their deletion, and then add them properly as submodules with git submodule add


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

1.4m articles

1.4m replys

5 comments

57.0k users

...