git add -A 没有在目录中添加所有修改过的文件 [英] git add -A is not adding all modified files in directories
问题描述
无论如何我都想添加所有文件:是否删除、创建、修改、未跟踪等?我只是不想 git add ALL 我的文件每次.我试过 git add -A
但它NOT 在文件夹中添加修改过的文件.
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.
这是我在项目中的初始 git status
:
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")
然后我把git add -A
:
Rakib-MacBook-Pro:my-xcode-practice rakib$ git add -A
然后这里是新状态 AFTER 做 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")
可以看到git status
没有任何变化.我该如何解决这个问题?
You can see that there has been no change in the git status
.
How do I solve this?
我也试过 git add .
- 它没有帮助
I also tried git add .
- it did not help
我也试过 git add *
- 它没有帮助
I also tried git add *
- it did not help
推荐答案
这里的问题是BankAccount
, BuckysButtons
, multiview
, rotator
和 segmentedControls
都是 git 子模块,它们在很多方面都像独立的存储库.
The problem here is that BankAccount
, BuckysButtons
, multiview
, rotator
and segmentedControls
are all git submodules, which act like independent repositories in many ways.
如果你想做的是在每个子模块中运行 git add -A .
,你可以这样做:
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'"
(如果这些子模块中没有嵌套其他子模块,则不需要 --recursive
选项.)
(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.
更新:从您在下面的评论中引用的错误消息看来,您是直接添加了这些其他 git 存储库而不是作为子模块添加的.如果您将另一个 git 存储库复制到您的存储库中,然后仅使用 git add
来暂存它,而不是使用 git submodule add
添加它,就会发生这种情况.如果您真的打算将它们存储为子模块,我建议将它们从存储库中移出,提交删除,然后使用 git submodule add
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
这篇关于git add -A 没有在目录中添加所有修改过的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!