git submodule showing up as a file in git status


git submodule showing up as a file in git status



I added a submodule and when I run git status it shows up as a file


Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: mysubmodule



should I commit this or add it to the .ignore file ?





After using git submodule add <subrepo URL>, you do need to commit the changes. And if your problem has been solved, you can accept the answer if it helps.
– Marina Liu - MSFT
Jul 3 at 6:31


git submodule add <subrepo URL>




1 Answer
1



Whenever there is a new submodule added, git creates a .gitmodules file and file for the submodule that you have added



.gitmodules file stores the project URL and local subdirectory mapping.


[submodule "mysubmodule"]
path = Mysubmodule
url = https://theurl



Although Mysubmodule is a subdirectory in your working directory, Git sees it as a submodule and doesn’t track its contents when you’re not in that directory. Instead, Git sees it as a particular commit from that repository.



So, You will need to commit both the .gitmodules file and the submodule file to git.



Please refer to git documentation for more details.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

JMeter fails on beanshell imports

Why in node-red my HTTP POST no receive payload from inject?

PHP contact form sending but not receiving emails