2

I have two local projects which I manage with git, one being dependent on the other – like this:

project A/
├── project B/     
│   ├── file B₁
│   ├── file B₂
│   ├── …

It makes sense to me to have project B as a git submodule of project A.

Now, I have set up a remote bare repository for project A for backup and sharing purposes. Of course, I want the remote repository to contain all of project B, including its files (file B₁, file B₂, …). But git push and git push --recurse-submodules=on-demand don’t achieve this. Whenever I list the files in my remote repository by git ls-tree -r HEAD, only the files of project A itself are listed. This does make sense to me.

However, is there a way to push the entire submodule project B to my remote base repository somehow, preferably in a clean way?

k.stm
  • 190
  • 13

3 Answers3

0

A submodule has to have a separate repository. Create a new bare repo and push your submodule to it.

phd
  • 82,685
  • 13
  • 120
  • 165
0

If B is actually a submodule, you should have a .gitmodule referencing it.
In that .gitmodule file, you would see the remote repo URL where B is pushed, in case there is any new commits done in B.

But B being a submodule means A won't have B files in it, only a reference to B SHA1.

If you want, you can un-submodule B (with my answer or this one) in order to keep all the B files in A.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

unfortunately submodule exists like SHA-1 code in parent module.so you should archive with another way:

  1. mkdir tmp_a && cd tmp_a
  2. git init && git remote add origin http://your/repo.git
  3. cd .. && rsync -a ./project_A/ ./tmp_a/ --exclude='*.git*'
  4. git add . && git commit -m"some log" && git push --set-upstream origin master

That works well

Anthony
  • 111
  • 1
  • 3