0

I'm currently working on a project where I've incorporated an external repository as a submodule using .gitmodules. Recently, I needed to introduce some custom functionality, so I made changes directly within the submodule and pushed them to my project's repository. However, when my team member pulled from my branch, they didn't receive the changes I made within the submodule.

Upon realizing that I lacked write access to the original submodule repository, I decided to fork it and use the forked repository's URL within .gitmodules. Subsequently, I made further changes within the submodule and attempted to push them to the forked repository. However, my changes were still being directed to the original repository, leading to my team member not receiving the updates.

What is the correct approach to update submodules in such scenarios, ensuring that changes made within the submodule are properly reflected for all team members pulling from the main project repository?

1 Answer 1

2

I decided to fork it and use the forked repository's URL within .gitmodules.

The best way to actually update the submodule's remote is with a git remote set-url <URL>. Always use Git's commands instead of performing manual edits.

In your case, just enter the submodule's folder and launch:

git remote set-url origin 'forked_URL'

The command will update the submodule's ref to your remote repository with the given URL.

Changes URLs for the remote. Sets first URL for remote that matches regex (first URL if no is given) to . If doesn’t match any URL, an error occurs and nothing is changed.

At this point, you should be able to push your changes to the forked repository.

Sign up to request clarification or add additional context in comments.

4 Comments

Can you please explain it a bit more? I didn't get it. @dani-vta
@RajaSaad I've expanded my answer and corrected --set-url with set-url
as soon(For now I have moved with another approach) as I am done resolving this, m gonna update you and mark your answer as accepted.
@RajaSaad did it work in the end?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.