SoftTimur
SoftTimur

Reputation: 5490

Move a git repository to another repository as a subfolder while keeping history

I have created and worked on a git repository github.com/softtimur/old. I just created another git repository github.com/softtimur/Documents, which has its own .../Documents/.git/. Now I want to create .../Documents/old and move everything of github.com/softtimur/old under it while keeping the commit history. And then, I want to remove github.com/softtimur/old.

Does anyone know how to do this moving properly?

Upvotes: 0

Views: 90

Answers (1)

nissefors
nissefors

Reputation: 440

I would add another remote to your local checkout of github.com/softtimur/old to allow you to to merge them and then push the result back

git clone [email protected]/softtimur/old.git
cd old
git remote add new [email protected]/softtimur/Documents.git
git fetch new
git checkout master
git merge new/master
git push -u new master

Upvotes: 1

Related Questions