Do you ignore a git submodule in your .gitignore or commit it to your repo?

前端 未结 3 453
猫巷女王i
猫巷女王i 2020-12-02 07:43

I\'ve added a submodule to my project in project_dir/vendor/submodule_one now each time I run git status I get modified: vendor/submodule_one

3条回答
  •  一向
    一向 (楼主)
    2020-12-02 08:08

    To add onto the accepted answer, I have found that adding the Git submodule folder to .gitignore actually causes issues - particularly when trying to create a fresh clone of the project. Specifically, running the normal submodule clone commands resulted in the submodule folder being empty:

    git submodule init
    git submodule update
    git pull --recurse-submodules
    

    Only by trying to re-run

    git submodule add  
    

    it was clear what the issue was, based on the output:

    The following path is ignored by one of your .gitignore files:
    
    Use -f if you really want to add it.
    

    Instead of adding -f, I removed the Git submodule folder from .gitignore and re-ran the submodule clone commands - which now successfully created the folder. I think that there may be a bug in that one of the submodule clone commands respects .gitignore but does not warn that it is skipping a submodule accordingly.

提交回复
热议问题