I have two repos, OGrepo
and Newrepo
. OGrepo
has two directories in it:
OGrepo
|-dirOne
|-dirTwo
I'd like to put a copy of Newrepo
inside of dirTwo
, including every single piece of commit history that happened to Newrepo
for its entire lifespan. I've been trying for a few hours to get this right, and have gone down some rabbit holes and now my OGrepo
is littered with random remotes and copies of Newrepo
at the same level as dirOne
and dirTwo
.
The closest I got was when I've done as this answer suggests and from my terminal being pointed at the root level of OGrepo
did the following:
git subtree add --prefix=dirTwo/Newrepo git://github.com/theUrlOf/Newrepo master
Then, I went cd dirTwo
typed git add *
and git commit -m"message"
followed by git push origin master
.
This does ok, all the intended files are in there and it looks good. But if I go into dirTwo/Newrepo
there and type git log
the only record that comes up is the the commit I just made to put it in there.
Next, I try the method laid out here:
cd path/to/OGrepo/dirTwo
git remote add Newrepo http://github.com/urlOf/NewRepo.git
git fetch Newrepo
git merge --allow-unrelated-histories Newrepo/master # this says 'already up to date when executing'
git remote remove Newrepo
So - after then adding * and pushing (to which it says everything is up todate). I check my github account and nothing is there.
Lastly, I have tried several different versions of this method, with this being the most concise way of stating it: https://stackoverflow.com/a/1426163/7082628
And that does something similar to the first thing I've tried. Creates the directory of Newrepo
in the right place, but the commit history is not preserved. Strangely enough, it preserves the commit history of all the other times this evening I've tried it this way, but that's it.
So, any ideas? Thanks!