0

I am switching all git repos (including the surepos referenced) to another server URL. My issue is that the .gitmodules file which is part of the GIT repository is still pointing to the OLD URL.

I changed this for the most recent commit to point to the new URL, however every older branch (old releases and commits) are pointing to the OLD URL.

Is there a way to change the .gitmodules files to point to the correct URL for all commits / branches?

This is the closest i could find to solve the issue, however for me it didn't work: Git submodule url changed

This is an generic issue, I should not be the only one with it, right?

Thanks in advance for any feedback!

marius
  • 1,118
  • 1
  • 18
  • 38
  • 2
    Since `.gitmodules` is part of the repository history, changing the URL for every commit would require rewriting every commit. – Stephen Newell May 12 '21 at 15:01
  • yes, so is there any function from GIT doing this? – marius May 12 '21 at 15:16
  • 1
    I'd argue it's a bad idea to completely rewrite the history of your project. At minimum, you're going to force everybody who's working with it to reclone. The history would be completely different from the time `.gitmodules` first appeared. Is that really what you want? – Stephen Newell May 12 '21 at 15:24
  • But what are the options? Leave the "old" urls in the "old" commits and releases? Imagine you have 100 different kind of releases (patches included) you will have to edit them manually? – marius May 12 '21 at 15:28
  • 2
    There are several ways to manage this, none of which are silver bullets. You're going to have to decide what's best for your project based on your requirements. Personally I'd leave the history pointing at the old URLs just to avoid rewriting history and write a script to update all "active" branches. If you want to change the history though, I don't know of any easy solution for that. – Stephen Newell May 12 '21 at 15:31
  • thats unfortunate ... thx ! – marius May 12 '21 at 15:59
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/232307/discussion-between-marius-and-stephen-newell). – marius May 12 '21 at 20:45
  • Not an answer to this question, but to avoid getting into this problem in the first place, I recommend using `../othermodule.git` for your URLs in `.gitmodules`, rather than absolute paths, so that when you move your repos to a different servers, submodules will keep working. I recommend switching to this approach so you don't face the problem again next time you change server. – joanis May 13 '21 at 14:32

0 Answers0