Alanpatchi
Alanpatchi

Reputation: 1199

Updating submodule URL

Till today, I was hosting my git repository and its submodule repository in github. And the submodule folder in all commits in the super-repository gets redirected to the correct commits in the submodule repository.

Now, I have to port the submodule repository from github to bitbucket and remove the submodule repository in github. Will this action break my commits in the super-repository? Don't the super-repositories commits store the submodule's url info in their commits?

Example scenario:

Lets say there is a commit c67061d7710e699a191965a02d9d0da341d87117 in submodule, that is referred in super-repository in many commits. I want to change that commit's reference from

githubserver/tree/c67061d7710e699a191965a02d9d0da341d87117

to

bitbucketserver/tree/c67061d7710e699a191965a02d9d0da341d87117

in all commits in the super-repository that contain's the reference to c67061d7710e699a191965a02d9d0da341d87117

I read about how to update the submodule's url in other stackoverflow questions here. But they don't clearly mention whether that url update changes references in all commits or just the commit's that follows such action.

Upvotes: 3

Views: 1007

Answers (1)

user3188445
user3188445

Reputation: 4774

The good news is that in the long run, this will work fine, because you will move all of your history from github to bitbucket and appropriately update your .gitmodules file. As soon as you do this, new checkouts and git submodule init will work fine.

The bad news is that existing checkouts will continue to use the old remote URL, so git submodule update will start to fail. To fix this, you will have to tell everyone who has checked out your repository to run git submodule sync, so as to update the remotes of the submodules to bitbucket.

Upvotes: 3

Related Questions