Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find current origin/master revision in submodule path

In my project (which uses git), I need to use a library, which is still in progress. I decided to create a submodule for that library, because I want to update from time to time its latest version (I don't plan to make my own change there).

I did:

git submodule add https://github.com/mb21/JSONedit.git git commit -am 'added JSNedit submodule' git push -u origin master git pull origin master 

Then, I did see the JSONedit folder in my local folder, and a link in my git folder online. But when I did git submodule update --remote JSONedit/, I got the following errors:

fatal: Needed a single revision Unable to find current origin/master revision in submodule path 'JSONedit' 

Does anyone know what's wrong here?

like image 241
SoftTimur Avatar asked Dec 06 '16 04:12

SoftTimur


People also ask

How do I initialize a git submodule?

If you already cloned the project and forgot --recurse-submodules , you can combine the git submodule init and git submodule update steps by running git submodule update --init . To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive .

How do I change my submodule location?

Git Submodules Moving a submodule If needed, create the parent directory of the new location of the submodule ( mkdir -p new/path/to ). Move all content from the old to the new directory ( mv -vi old/path/to/module new/path/to/submodule ). Make sure Git tracks this directory ( git add new/path/to ).

How do I clone a submodules repo?

The list of steps required to clone a Git repository with submodules is: Issue a git clone command on the parent repository. Issue a git submodule init command. Issue a git submodule update command.

Do submodules automatically update?

Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.


1 Answers

Running this in the main repository should do the trick:

git pull --recurse-submodules 

According to the other discussion, especially as @Tobu pointed out in his comment over there, if the error persists, it might be needed to first:

remove both the submodule worktree (ext/blah) and the matching folder inside the GIT_DIR (.git/modules/ext/blah)


Alternatively, you could git checkout the branch from which you want to pull while inside the submodule, and then run a git pull.

Results should be the same.

like image 129
tehp Avatar answered Oct 06 '22 15:10

tehp