git add -A不会添加目录中的所有修改的文件 [英] git add -A is not adding all modified files in directories

查看:688
本文介绍了git add -A不会添加目录中的所有修改的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,我想添加所有文件:是否删除,创建,修改,未跟踪等?我只是不想git添加所有我的文件每次。我试过 git add -A ,但它是不是在文件夹内添加修改过的文件。



这是我在项目中的初始 git status



pre $ Rakib- MacBook Pro:my-xcode-practice rakib $ git status
#在分支主机上
#没有为commit提交更改:
#(使用git add< file> ...更新将提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)
#(提交或放弃子模块中未跟踪或修改的内容)

#修改:BankAccount(修改内容,未跟踪内容)
#修改:BuckysButtons(修改内容,未跟踪内容)
#修改:multiview )
#modified:rotator(修改内容,未跟踪内容)
#modified:segmentedControls(修改内容,未跟踪内容)

没有更改添加到提交中(使用git add 和/或git commit -a )

然后我把 git add -A

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

然后这里是新的状态 AFTER 完成 git add -A $ b $ pre $ R code $ R $ g
$分支大师
#没有为commit提交更改:
#(使用git add< file> ...来更新将提交的内容)
#(使用git checkout -
#(在子模块中提交或放弃未跟踪或修改的内容)

#修改:BankAccount(修改后的内容,未跟踪的内容,< file>内容)
#修改:BuckysButtons(修改内容,未跟踪内容)
#修改:多视图(修改内容,未跟踪内容)
#修改:旋转器(修改内容,未跟踪内容)
#修改:segmentedControls(修改后的内容,未被跟踪的内容)

未提交更改(使用git add和/或git commit -a)

你可以看到 git status 没有变化。
我如何解决这个问题?



我也尝试过 git add。 - 没有帮助

我也试过 git add * - 它没有帮助

解决方案

这里的问题是 BankAccount BuckysButtons multiview rotator segmentedControls 都是git子模块,它们在很多方面都像独立的存储库一样。



如果你想要做的是在每个子模块中运行 git add -A。,你可以这样做:

  git submodule foreach --recursive git add -A。 

然后您可以在每个子模块中创建一个提交:

  git submodule foreach --recursivegit commit -m'提交子模块'

(如果没有其他子模块嵌套在这些子模块中,则不需要 - 递归选项。 p>

然而,我不建议这样做。您应该小心地依次更改为每个子模块,并考虑如何更新它们,将每个子模块视为独立存储库。然后,只有在测试过整个项目适用于每个子模块的新版本时,才在主项目中提交这些新的子模块版本。




更新:从错误消息看来,您已经在下面的评论中引用了您直接添加了这些其他git存储库而不是子模块。如果您将另一个git存储库复制到您的存储库中,然后仅使用 git add 来分阶段执行,而不是使用 git submodule add< ; REPOSITORY-URL> 。如果你真的打算将它们存储为子模块,我建议将它们移出存储库,提交它们的删除,然后将它们作为子模块正确添加为 git submodule add


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

解决方案

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

这篇关于git add -A不会添加目录中的所有修改的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆