tags:

views:

17

answers:

0

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?