oe7drt-website/content/posts/2022/33-change-git-submodule-url/index.md

43 lines
932 B
Markdown
Raw Normal View History

2022-12-05 22:32:44 +01:00
+++
title = "Change git submodule URL"
aliases = '/posts/2022-11-26-change-git-submodule-url'
2022-12-05 22:32:44 +01:00
summary = """Another thing I forget constantly when using git:
Changing the remote URL of a submodule"""
date = "2022-12-01T20:08:17+01:00"
2024-09-29 01:48:06 +02:00
lastmod = '2024-09-28T23:48:06+0000'
2022-12-05 22:32:44 +01:00
categories = ["computerstuff"]
2023-04-10 09:54:18 +02:00
tags = ["git"]
2022-12-05 22:32:44 +01:00
+++
If the location (URL) of the submodule has changed, then you can simply:
1. Modify the <kbd>.gitmodules</kbd> file in the repo root to use the new URL.
2022-12-13 06:38:30 +01:00
2. Delete the submodule folder in the repo
2024-09-29 01:48:06 +02:00
```console
$ rm -rf .git/modules/<submodule>
```
2022-12-13 06:38:30 +01:00
3. Delete the submodule folder in the working directory
2024-09-29 01:48:06 +02:00
```console
$ rm -rf <submodule>
```
2022-12-13 06:38:30 +01:00
4. Run
2024-09-29 01:48:06 +02:00
```console
$ git submodule sync
```
2022-12-13 06:38:30 +01:00
5. And run
2024-09-29 01:48:06 +02:00
```console
$ git submodule update
```
2022-12-05 22:32:44 +01:00
More complete info can be found elsewhere:
<https://stackoverflow.com/questions/913701/changing-remote-repository-for-a-git-submodule>