Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding a git submodule that tracks master

I'm using git 1.8.4 and trying to add a submodule that tracks master of another repository. I tried adding it as follows:

git submodule add -b master /path/to/myrepo.git

And I get the following error when I try to add it

Cloning into 'myrepo.git'...
warning: You appear to have cloned an empty repository.
done.
fatal: Cannot update paths and switch to branch 'master' at the same time.
Did you intend to checkout 'origin/master' which can not be resolved as commit?
Unable to checkout submodule 'myrepo'

I'm not sure what this means...can someone explain?

like image 639
Jeff Storey Avatar asked Jul 13 '26 16:07

Jeff Storey


1 Answers

The fact that the submodule doesn't appear to have a branch (ie: "cd submodule ; git branch -avvv" doesn't return anything, means the submodule configuration in the parent repo isn't properly initialized and updated.

I commented:

One way to move forward would be to start from a fresh clone of the parent repo (without any reference to your submodule), and repeat the steps:

git submodule add -b master /path/to/myrepo.git ; 
git submodule update --remote --init. –
like image 125
VonC Avatar answered Jul 15 '26 05:07

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!