Git submodule add error
Clash Royale CLAN TAG#URR8PPP
Git submodule add error
I want to add a submodule on a freshly created git repository and I get an error. If I execute the same command again it succeeds.
C:>mkdir MyRepo
C:>cd MyRepo
C:MyRepo>git init
Initialized empty Git repository in C:/MyRepo/.git/
C:MyRepo>git submodule add -b refs/heads/master C:MySubmodulesLibraryMySubmodule MySubmodule
Cloning into 'C:/MyRepo/MySubmodule'...
done.
fatal: 'origin/refs/heads/master' is not a commit and a branch 'refs/heads/master' cannot be created from it
Unable to checkout submodule 'MySubmodule'
C:MyRepo>git submodule add -b refs/heads/master C:MySubmodulesLibraryMySubmodule MySubmodule
Adding existing repo at 'MySubmodule' to the index
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory.
Git version: 2.17.1.windows.1
2.17.1.windows.1
I'd like to know what am I doing wrong and what can I do to make this operation succeed the first time I execute it.
*This question comes as a follow up of a Git Extensions bug where the first time you try to add a submodule it fails but the second time it succeeds. These are the commands issued by Git Extensions when adding a submodule; however, the same behavior occurs when issuing them from the command line. I don't know if this behavior is expected from Git (and the problem is with Git Extensions issuing the wrong commands) or this is a Git bug.
refs/heads/master
Because that is what Git Extensions does.
– Jordi
Aug 8 at 13:05
1 Answer
1
Try to use
git submodule add -b master C:MySubmodulesLibraryMySubmodule MySubmodule
-b
is the simple branch name.
-b
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Why are you using
refs/heads/master
?– evolutionxbox
Aug 6 at 10:56