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:

  • What is the quickest way to manage Git over a network?
  • How does git keep track of versions in the remote repository?
  • Git: I need to add files that live above the repo root
  • How to merge remote master to local branch
  • Unable to use key file Eclipse
  • Creating staging and production versions of a site on Github Pages
  • 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

  • Which version control tool is best suited to handle reflective or cyclic merging? SVN, Git?
  • bitbucket how to return branch from “merged” into “active”
  • Reverting to a previous commit in Git for visual studio 2012
  • cannot connect to my repository in AWS Code commit
  • Browsing two different revisions of the same repository
  • git diff file between two last commits that changed it
  • 8 Solutions collect form web for “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?

    I didn’t really know how to fix this properly with git, so I duplicated the directory, and deleted the original.

    cp subfolder newsubfolder    
    rm -rf subfolder
    

    Then I added all changed files, committed, and pushed.

    git add -A
    git commit -am 'i did something and there are now files'
    git push origin <branchName>
    

    I solved this by deleting the .git folders inside the supposed submodules and inside the project root, and then doing a new ‘git init’

    A pretty simple fix for me – I had opened the Git Bash in a subdirectory of the project.

    Open the Bash and doing the commands in the root directory fixed this problem; git add -A . worked as expected.

    Let’s quote the documentation for -A:

           -A, --all
           Like -u, but match <filepattern> against files in the working tree in addition to the
           index. That means that it will find new files as well as staging modified content and
           removing files that are no longer in the working tree.
    

    Note the critical word: <filepattern>. You need to give it a pattern that matches, recursively, all the way down your tree.

    I had a similar problem on Windows where I git add --all left some files untracked, problem was that there were several files with different casing ‘test.php’ and ‘Test.php’ so git tracked Test.php and not lowercase version of it.

    This may help someone in future and save some head scratching.

    I had this very issue the past couple of days with BitBucket. I am working on a project that is being tracked in its repository by Visual Studio 2013 Community Edition.

    However I had used Git Bash on occasion to manually do commits and that’s when things started to go wrong and files were simply being ignored. Tried to reclone the repo but this didn’t help.

    Finally I found that if you go into Visual Studio > Team Explorer > click on Sync, Visual Studio will do a pull and then commit and push any untracked files.

    You could do the same manually through Git Bash if you like the console like I do.

    Hope this helps someone.

    I had this issue because I cloned somebody else’s repository into my project. When I cloned it, there were already .git and .gitignore folders/files from their project. After deleting those pre-existing git files and starting over with git again, it works fine.

    Git Baby is a git and github fan, let's start git clone.