How do I create a new zeroed submodule in git?

Asked

Viewed 97 times

1

What’s the most practical way to create a new, empty submodule in git? Whenever I need to I’m having to create outside to then checkout with a url. Do you have any more direct way with one or a few commands, leaving the repository already as submodule and initialized? without even remote? (I’ll add it to the IDE when I go up)

1 answer

1


There are a few different ways to deal with git submodules. I don’t quite understand what you’re up to, but see if it’s some of those options:

Create a submodule by specifying a particular branch in a remote repository

git submodule add -b <branch> [URL to Git repo]  
git submodule init

Onde <branch> é a branch para onde você quer commitar o submodulo e a
[URL] é o caminho do repositório remoto.

Create a submodule from a repository folder

git init .
mkdir submodule
cd submodule
git init .
cd ..
git submodule add ./submodule submodule

I wrote "more verbose" to help understand what happens. You can add a folder as a local submodule and then push to the remote.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.