Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git submodule for Linux and Windows

When using git submodule on Linux I might have a .gitmodules with one or more subsystems checked out from e.g. /mnt/gitrepos/subsystem1.git (central file based access).

[submodule "subsystem1"]
  path = subsystem11
  url = /mnt/gitrepos/subsystem1.git/

I would like to support also a Windows user who can access the same module repo from H:/gitrepos/subsystem1.git/.

It is e.g. a Samba share from Linux of /mnt/gitrepos/ as the share gitrepos.

Is there a way where Git can handle the URL line depending on the OS? For Windows the .gitmodules would be

[submodule "subsystem1"]
  path = subsystem11
  url = H:/gitrepos/subsystem1.git/

Thus I would like "something like" this generic code for .gitmodules (speculative syntax):

[submodule "subsystem1"]
  path = subsystem11
  if Linux 
    url = /mnt/gitrepos/subsystem1.git/
  else
    url = H:/gitrepos/subsystem1.git/
like image 981
Peter Toft Avatar asked Sep 17 '26 06:09

Peter Toft


1 Answers

No. Submodules are generally designed for one repository URL that works everywhere, usually network-based (e.g. git://host/path). There is no mechanism for providing multiple different URLs for one repository.

That said, Git does allow you to customize a submodule's URL. When submodules are initialized (git submodule init), the URL from .gitmodules is copied to your .git/config file. You can now edit the URLs there before running git submodule update.

like image 171
Jan Krüger Avatar answered Sep 18 '26 20:09

Jan Krüger



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!