I'm using Git's subtree command to pull a couple of libraries in to a project.
If I then clone the project in the normal way, I end up with all the code that I need, but I lose the subtree relationships - in the clone there is no remote for each of the libraries, and there is no -push branch for either of them.
What's the best way to re-establish this connection?
Is it sufficient to do
git remote add <lib> <remote-url>
git fetch <lib>
If I was adding the library for the first time I'd follow that with:
git subtree add -P <local/lib> --squash "<lib>/master"
This doesn't work when the local directory already exists though, which of course it will when you've cloned a project that has already had the library added to it.
Is there anything else that one should do in this situation, to ensure that subsequent git subtree merge and git subtree split commands to the expected thing?
The way that I have in the past re-created that relationship was by doing a subtree merge.
git pull -s subtree <lib> master
even if there is nothing to merge in/pull it should simply return without doing anything. Feel free to add --squash
to the above pull so that you don't pull in any remote history.