How to get rid of Git submodules untracked status?

后端 未结 10 1457
轻奢々
轻奢々 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:40

    This probably happens when you have another .git [hidden folder] inside the particular folder..

    modified: ./../.. (modified content, untracked content)

    make sure your sub-directory does not contains this .git folder.

    If That is the case the issue can be resolved by deleting the .git folder manually from the sub directory.

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

    This worked out just fine for me:

    git update-index --skip-worktree <path>
    

    If it doesn't work with the pathname, try the file name. Let me know if this worked for you too.

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

    Since the git status reports untracked content, the actual way to have a clean status would be to go into each one of those submodules and:

    • add and commit the untracked contents,
    • or reference the untracked contents in a .gitignore specific to each module.
    • or you can add the same ignored content to the submodule's .git/info/exclude, as peci1 reports in the comments.
    • or add dirty to the submodule specification, as mentioned in ezraspectre's answer (upvoted).

      git config -f .gitmodules submodule.<path>.ignore untracked
      
    • or add a global .gitignore file (often ~/.gitignore-global). Like for example .DS_Store or in my case Carthage/Build as reported by Marián Černý in the comments. See .gitginore man page:

    Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.

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

    You can also go to each submodule dir and act as a separated git. For example:

    cd my/project/submodule
    git status
    

    ... /gets the list of modified files/

    git add .  //to add all of them to commit into submodule
    git commit -m "message to your submodule repo"
    

    you can also update your remote submodule repo with

    git submodule update
    

    after all

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