threads / discuss / 28645

Submodule confusion when checking out branch

Subject: Submodule confusion when checking out branch

## tl;dr

2 messages between Oct 11, 2011 and Oct 11, 2011.

replies: 1people: 2as markdown or json

Howard Miller· Oct 11, 2011, 09:38 UTC · lore
I added a submodule to my project like this (all from the root of the project)

git submodule add git@.....   path/to/submodule git submodule init git add path/to/submodule git commit -m 'I added a submodule!' git push

All looks good and 'git status' reports 'nothing to commit'
However, I now cannot change branches. On checkout, I get...

"error: The following untracked working tree files would be overwritten by checkout:" (followed by a big list of all the files in the submodule)

Where did I go wrong and what can I do to sort it?
Thanks again!
Jens Lehmann· Oct 11, 2011, 17:35 UTC · re: Howard Miller · lore

Re: Submodule confusion when checking out branch

Am 11.10.2011 11:38, schrieb Howard Miller:
Show 17 quoted lines
> I added a submodule to my project like this (all from the root of the project)
> 
> git submodule add git@.....   path/to/submodule
> git submodule init
> git add path/to/submodule
> git commit -m 'I added a submodule!'
> git push
> 
> All looks good and 'git status' reports 'nothing to commit'
> 
> However, I now cannot change branches. On checkout, I get...
> 
> "error: The following untracked working tree files would be
> overwritten by checkout:"
> (followed by a big list of all the files in the submodule)
> 
> Where did I go wrong and what can I do to sort it?

Hmm, as I don't know for what checkout you see this problem (do you switch from a branch containing the submodule to one that doesn't have it or the other way round?) and assuming you had some files committed in the directory where the submodule lives I can take a guess what happened:

Could it be the case that you converted an existing directory into a submodule and then get this error when you want to switch back to a branch where this directory is still filled with the original files?

Then this is a known shortcoming of submodules at the moment. I have experimental code to make Git work in that case but it is not ready for inclusion yet.

← back to recent threads