How to get rid of Git submodules untracked status?

后端 未结 10 1456
轻奢々
轻奢々 2020-12-07 08:14

I can\'t seem to get rid of untracked content in Git\'s submodules. Running git status yields:

# On branch master
# Changes not staged for commit:
#          


        
相关标签:
10条回答
  • 2020-12-07 08:22

    In my situation I clone modules as a starting point for a new module in my ZF2 environment. What this does is put its own .git folder into the directory.

    Solution in this case is to delete the .git folder (you will likely need to show hidden files to view it).

    0 讨论(0)
  • 2020-12-07 08:28

    I prefer to use SourceTree, so the solution for me was to open the submodule repo in SourceTree which shows me list of all untracked files. I then group selected them all then used "Remove".

    I was able to do this because I knew all the untracked files weren't actually needed.

    0 讨论(0)
  • 2020-12-07 08:31

    If this is a temporary issue, you can go into the submodule folder and run git reset HEAD --hard but you will lose all your changes inside of the submodule.

    0 讨论(0)
  • 2020-12-07 08:32

    It could be due to the detached HEAD in your submodule branch. If this is the case, go into your submodule path (e.g.: ./bundle/snipmate), then rungit checkout master.

    0 讨论(0)
  • 2020-12-07 08:35

    I found this blog post to work overall. By adding the ignore = dirty option to each one of the entries in the .gitmodules file.

    [submodule "zen-coding-gedit3"]
        path = zen-coding-gedit3
        url = git://github.com/leafac/zen-coding-gedit3.git
        ignore = dirty
    
    0 讨论(0)
  • 2020-12-07 08:39

    I got stuck on this issue yesterday, in a project which had close to 12 submodules.

    git status was showing output.

    # On branch master
    # Changes not staged for commit:
    #   (use "git add ..." to update what will be committed)
    #   (use "git checkout -- ..." to discard changes in working directory)
    #   (commit or discard the untracked or modified content in submodules)
    #
    #   modified:   proj1 (untracked content)
    #   modified:   proj1 (modified content, untracked content)
    #   ...
    

    To resolve the untracked content error, I had to remove the untracked files from all submodules (all were *.pyc, *.pyo files generated by python) using a .gitignore.

    To resolve the other, I had to run git submodule update which updated each of the submodules.

    0 讨论(0)
提交回复
热议问题