Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 587
ir2pid Avatar asked Oct 23 '25 14:10

ir2pid


1 Answers

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.

like image 96
Mamtha Soni K Avatar answered Oct 26 '25 04:10

Mamtha Soni K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!