git add -A is not adding all modified files in directories
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
I just recreated this by accident.
I copied a project I had in another folder into my new git repo. I didn't intend to use it as a submodule, I intended to use it as a starting point for a new project. The project I copied which was now a subfolder of my main git repo had .git/
in it. Delete subfolder/.git/
.
rm -rf subfolder/.git
Then things were still weird...
git status
Nothing to commit. Hmm... What about all of these files?
The reason is the files are still cached in git as a submodule - this cache needs to be cleared of that:
git rm --cached subfolder
You should now see that all of the files in the subfolder in git status
.
You can now commit and push.
git add -A
git commit -m 'fix: rm accidental submodule and readd files'
git push origin <branch>