Git submodules – Why changing a submodule URL and push that commit causes problems to everyone who already had a copy of the parent repo?

im working on a project with some submodules, but for this question lets say i only have one

Im going to call my “parent repo” as PR and my submodule as “SM”

Lets say two dudes have a clone of the PR, but one of the change the url of the repo; although he can do a manual change to the .gitmodules file (changing the URL os the SM) and then :

git submodule sync SM 

He prefers to do a

git submodule set-url SM newUrl

And then he wants to rename the SM to “SMX” so he does a:

git mv SM SMX

(For what i know, by checking the .gitmodules and .git/config, everuthing is fine till this point right?)

So then he does a :

git submodule update --remote

To update his local SMX directory

He commits everything and decide to push it


So now, i have my own copy and i notice this changes to the remote PR.
For what i read in the “Pro GIT” book:

There is a special situation that can happen when pulling superproject updates: it could be that the upstream repository has changed the URL of the submodule in the .gitmodules file in one of the commits you pull. This can happen for example if the submodule project changes its hosting platform. In that case, it is possible for git pull –recurse-submodules, or git submodule update, to fail if the superproject references a submodule commit that is not found in the submodule remote locally configured in your repository. In order to remedy this situation, the git submodule sync command is required:

# copy the new URL to your local config
$ git submodule sync --recursive
# update the submodule from the new URL
$ git submodule update --init --recursive

Soooooooo, for the

git submodule sync

The Git documentation says this:

Synchronizes submodules’ remote URL configuration setting to the value specified in .gitmodules. It will only affect those submodules which already have a URL entry in .git/config (that is the case when they are initialized or freshly added)

Sooooo, because i already had initialized the SM submodule i my local copy, when i do a

git pull origin

And then a

git submodule sync --recursive

Now my .gitmodules is synchronized with my local .git/config (I GUESS, LET ME SEE IF IM WRONG PLEASE)

So now if i do a

git submodule update --init --recursive

(I think, in this particular case a ‘git submodule update’ or ‘git submodule update –remote’ will work just fine, but ‘git submodule update –init –recursive’ will work too but is in this particular case not the best choice)

I will update my local SM -> SMX right?, but it gives me this output

fatal: remote error: upload-pack: not our ref cee0718a58c2f7dc4a8d29da5b9ede1354bc153c
fatal: Fetched in submodule path ‘SMX’, but it did not contain cee0718a58c2f7dc4a8d29da5b9ede1354bc153c. Direct fetching of that commit failed.

The i tried with

git submodule update --remote

And this gives me no error but it doesnt do anything, it doesnt upate my local SM to SMX

I want to clarify that in my PR in GITHUB the pushed commit of my partner its good, i mean, in the PR, the reference to SMX works fine, with this i mean that, this reference “cee0718a58c2f7dc4a8d29da5b9ede1354bc153c” does exists in SMX submodule

So why is this happenning? is this happening because of changing the submodule name (in this example from SM to SMX)?

Why is this happening and how to solve it?

Thanks in advance !!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật