Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git SourceTree - Uncommitted Submodules

Tags:

git

bitbucket

I've cloned a repository on my local machine (Xcode iOS project) that contains a 3 submodules.

One of the submodules is private and inaccessible to me so I commented it out of the .git/config file so I could do some work.

Now I've come to commit my changes and have been presented with the following dialog -

Uncommitted submodules dialog

My question is - What happens if I click skip and push my changes to the remote repository. Will it effect other developers (who have access to the private submodule) who pull my commit. I'm reluctant to push in case it removes the submodule from the remote repo.

Hope that makes sense, and thanks in advance for any comments or answers.

Cheers, Adam

[UPDATE] This article seems to suggest that hitting skip will leave any changes uncommitted and won't be pushed to the remote. http://blog.sourcetreeapp.com/2012/02/01/using-submodules-and-subrepositories/

like image 647
adamS Avatar asked Jul 23 '14 12:07

adamS


People also ask

What is the point of Git submodules?

Git submodules allow you to keep a git repository as a subdirectory of another git repository. Git submodules are simply a reference to another repository at a particular snapshot in time. Git submodules enable a Git repository to incorporate and track version history of external code.

When should I use Git submodules?

In most cases, Git submodules are used when your project becomes more complex, and while your project depends on the main Git repository, you might want to keep their change history separate. Using the above as an example, the Room repository depends on the House repository, but they operate separately.

Where are submodules stored in Git?

A submodule can be located anywhere in a parent Git repository's working directory and is configured via a . gitmodules file located at the root of the parent repository. This file contains which paths are submodules and what URL should be used when cloning and fetching for that submodule.


1 Answers

Submodules are like code references within repositories. Think about them as a pointer to another repo.

It's important to understand that when you check out submodule a local copy of submodule repo is present in your disk and if there are any intended/unintended changes in submodules you are asked for the above prompt.

To answer your question: If you press skip then only changes in your repo will be committed and submodule remote will be left intact. This may make your code unstable if you are relying on those changes in the submodules.

If you press commit then your changes in submodule will be committed as well.

It's generally a good practice to make any changes in submodules separately and pull those changes in your repo. If the submodules are actively used then I would recommend using a dependency manager or git subtrees to reference it.

enter image description here

like image 114
Kunal Balani Avatar answered Sep 28 '22 03:09

Kunal Balani