git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Submodule relative URL problems

From
LTLianheng Tong <lianheng.tong@kcl.ac.uk>
Date
Jan 13, 2014, 14:02 UTC
Message-ID
<DAD6CF7D-49F2-4FB5-9EF2-EBAAF86881AA@kcl.ac.uk>
In-Reply-To
<DC691CA7-BE36-4FE7-895A-FE8E1FD0C080@kcl.ac.uk>
Hi All,
I am currently working on a project, call it A, which contains several sub-projects B, C, D.  The B, C, D are actually experimental input and outputs for simulation runs, which I need to keep track of the daily changes.  Most of these calculations are done on workstation, but I do need to occasionally clone the repositories to other machines, and then push the updates back.
I version track B, C and D with independent git repositories, and organisationally it makes sense for them to be subdirectories of A.  I would like to version control the overall project A, with B, C, D as submodules.
This is easily done on the main workstation (I will call it W1), with:
cd A
git init
for ii in B C D ; do
  git submodule ./${ii}/.git
done
git add .
git commit
Repository A/.git on W1 does not have an origin.  All seems to work fine with this step up on W1.
HOWEVER, problem starts to appear when I attempted to clone the overall repository A to another workstation W2:

git clone W1:<path to A on W1>/.git <path to A on W2> cd <path to A on W2> git submodule init git submodule update

git then produces an error indicating that:
W1:<path to A on W1>/.git/B/.git
is not a valid repository (i.e. directory not found)
The extra .git has been inserted in the URL to submodule repository B, C, and D.
This can be solved by changing the .gitmodules file, replacing ./B/.git to ../B/.git,  and then git submodule sync on W2.
However, this is far from being an optimal solution, because if .gitmodules on W1 is updated accordingly, then the submodule repository for B would point to
<path to A on W1>/../B/.git
which will be incorrect.  I could in principle define the URL for the submodule repositories as absolute paths, but keeping them relative to A has many advantages, such as I will be able to move A around, without effecting the main repositories on W1 in anyway, and I can rsync them to another disk for backup etc.
I would be very grateful if someone can offer me an solution to my problem.
Many thanks in advance!
Lianheng

================================================ Lianheng Tong Tel: +44 79 1758 3822 Room S4.02, Strand Building Fax: +44 20 7848 2420 Department of Physics lianheng.tong@kcl.ac.uk Kings College London Strand, London WC2R 2LS, U.K. ================================================

Next: Jonathan Nieder
Message 1 of 4 in “Submodule relative URL problems”
  1. Lianheng TongJan 13, 2014
  2. Jonathan NiederJan 13, 2014
  3. Heiko VoigtJan 13, 2014
  4. Junio C HamanoJan 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.