0

Let's say I have a repositiory Repo and now I want to add folder Common which is separate repository. So the structure should be as following:

Repo
    myfile.txt
    Common
        anotherfile.txt

As I know there are at least 2 ways to do that: subtrees and submodules. After reading some git tutorials and manuals I came to the conclusion that subtree is what I want.

Ok, so I've added the folder to my repo:

git subtree add --prefix Common https://github.com/my/Common.git master --squash

Ok, now it looks as expected. After some time I want to update the subtree folder. But unfortunately the only way I've found so far is:

git subtree pull --prefix Common https://github.com/my/Vommon.git master --squash

Why should I again enter the repository Url? Isn't that stored somewhere in the git structure? What if I have several subtrees? I don't think that someone remember all the urls.

Is there a way to do that in some simple way? Maybe I'm missing something?

folibis
  • 12,048
  • 6
  • 54
  • 97

1 Answers1

0

Why should I again enter the repository Url? Isn't that stored somewhere in the git structure?

Nop. The URL is stored with submodules but not with subtrees. A subtree is fully integrated into the repository, it doesn't remember it's a separate subtree, it doesn't remember where it came from.

What if I have several subtrees?

Create git aliases or shell aliases or scripts to pull/push many subtrees.

Or switch back to submodules. They have many disadvantages but at least they remember from where they were cloned.

phd
  • 82,685
  • 13
  • 120
  • 165