I try to add a subtree using a relative url:
> git subtree add --prefix child ../child.git master --squash
git fetch ../child.git master
fatal: '../child.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
But ../child.git
, relative to this repository's remotes, is a git repository that I have full rights to. You can see this if I try to add it as a submodule:
> git submodule add ../child.git child
Cloning into 'D:/code/jjj/subtree/parent/child'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
I can add this child repository as a subtree fine if I use an absolute URL, and I can add it fine as a submodule if I use a relative URL.
Is it possible for me to add it as a subtree using a relative URL?
I was fundamentally misunderstanding subtrees when I asked this question.
Subtrees don't maintain a connection to the "child" repository. Instead, the files from the repo are read in, and that's it.
As such, there's no point or need in using relative paths. Instead, one should use the absolute path (if using a URL -- relative filepaths can be used).