{"id":16123660,"url":"https://github.com/austenstone/migrate-submodules","last_synced_at":"2026-05-02T19:31:25.198Z","repository":{"id":106376627,"uuid":"452081634","full_name":"austenstone/migrate-submodules","owner":"austenstone","description":"Migrate submodules recursively using sed","archived":false,"fork":false,"pushed_at":"2022-02-28T13:57:05.000Z","size":54,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T12:16:50.748Z","etag":null,"topics":["git","git-submodules","submodules"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/austenstone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["austenstone"]}},"created_at":"2022-01-25T23:54:29.000Z","updated_at":"2022-01-27T03:27:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f4eaeb3-d44b-4f31-a7f9-288dd94e8e33","html_url":"https://github.com/austenstone/migrate-submodules","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/austenstone/migrate-submodules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fmigrate-submodules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fmigrate-submodules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fmigrate-submodules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fmigrate-submodules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/austenstone","download_url":"https://codeload.github.com/austenstone/migrate-submodules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fmigrate-submodules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32547644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","git-submodules","submodules"],"created_at":"2024-10-09T21:18:09.791Z","updated_at":"2026-05-02T19:31:25.158Z","avatar_url":"https://github.com/austenstone.png","language":"Shell","funding_links":["https://github.com/sponsors/austenstone"],"categories":[],"sub_categories":[],"readme":"# Migrate Submodules\n\nGit migrations tools like [GitHub Importer](https://docs.github.com/en/get-started/importing-your-projects-to-github/importing-source-code-to-github/importing-a-repository-with-github-importer) and even [ghe-migrator](https://docs.github.com/en/enterprise-server@3.3/admin/user-management/migrating-data-to-and-from-your-enterprise/migrating-data-to-your-enterprise) are not able to update [submodule urls](https://git-scm.com/docs/gitmodules#Documentation/gitmodules.txt-submoduleltnamegturl). This small script solves that problem by updating all your `.gitmodules` files recursively with a simple [sed](https://linux.die.net/man/1/sed) command.\n\n[Install](https://github.com/austenstone/migrate-submodules#install-%EF%B8%8F)\n\nYou can run this script in any git repository and it will recursively itterate submodules and perform the following operations:\n1. Executes the sed command provided via `-s` on .gitmodules\n2. Synchronizes submodules' remote URL configuration setting to the value specified in .gitmodules\n3. Updates(pulls) all submodules.\n4. Commits the changes to the branch provided via `-b` with the message provided via `-m`\n\n#### NOTES\n- You must have read/write permission on the repositories you are modifying\n- This script will not import repositories for you and assumes all required repositories have already been imported to your target. This means if you are replacing the url of a submodule, the new URL must be pointing to a valid repository.\n\n## Usage 🏃‍♂️\nThis example is migrating the url from `bitbucket.org` to `github.com`.\n\nClone your repo that contains submodules and cd inside:\n```bash\ngit clone https://austenstone@bitbucket.org/austenstone/main-test1.git\ncd main-test1\n```\n\nRun the script:\n```bash\nmigrate-submodules.sh -s 's/bitbucket.org/github.com/g' -b 'master'\n```\nCongratulations. Your submodules have been updated! 🎉\n\nCheck them out 👀\n```bash\ncat .gitmodules \u0026\u0026 git submodule foreach --recursive '[ -f .gitmodules ] \u0026\u0026 cat .gitmodules || true'\n```\n\nIf you are happy with the results, push your changes to remote:\n```bash\ngit submodule foreach --recursive git push origin master\ngit push origin master\n```\n\nTIP: You can automatically sync all branches with master by running the following command:\n```bash\nfor BRANCH in `ls .git/refs/heads`; do git rebase master $BRANCH; done\ngit push --all origin\n```\n\nTo see this example in action read the [GitHub Actions workflow](https://github.com/austenstone/migrate-submodules/blob/main/.github/workflows/blank.yml) and also checkout the [previous runs](https://github.com/austenstone/migrate-submodules/actions/workflows/blank.yml).\n\n## Install ⬇️\nSimply add the script to your PATH.\n```bash\ncd /usr/local/bin\ncurl https://raw.githubusercontent.com/austenstone/migrate-submodules/main/migrate-submodules.sh \u003e migrate-submodules.sh\nchmod +x migrate-submodules.sh\n```\nScript tested on Ubuntu and MacOS.\n\n## Test Repo Hierarchy\n[bitbucket.org/austenstone/main-test1](https://bitbucket.org/austenstone/main-test1) is the root of a small set of repos and is used to test the functionality.\n\n[github.com/austenstone/main-test1](https://github.com/austenstone/main-test1) is the migrated repo.\n```mermaid\ngraph TD;\n    main-test1--\u003echild-test1;\n    child-test1--\u003echild-test1-child ;\n    main-test1--\u003echild-test2;\n```\n\n## Possible Improvements 🚧\n- Use `set-url [--] \u003cpath\u003e \u003cnewurl\u003e` instead of sed.\n- Sync all branches in the script\n- Dynamically get the default branch using `git remote show origin | sed -n '/HEAD branch/s/.*: //p'`\n\n## Inspiration ✨\n- [Enteee/git-submodule-url-rewrite](https://github.com/Enteee/git-submodule-url-rewrite)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustenstone%2Fmigrate-submodules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustenstone%2Fmigrate-submodules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustenstone%2Fmigrate-submodules/lists"}