0

I have a repository with a lot of file history that I don't want to lose. I now have a new repository that I would like to "put into" the old repository so it has the old name and the file history. How can I do this?

Hugo y
  • 1,421
  • 10
  • 20
Stephanie Fu
  • 79
  • 1
  • 9

1 Answers1

-1

That is not how Git works. You just cannot put a new repository into an old one.

Option 1 - Create new repository:

  • Create the new repo
  • Clone all the content from the old repo into the new one
  • Commit all new files/data to the new repo

All people working with the old one now need to switch their repo remote url to the new repository name.

Option 2 - Work with branches:

  • Create a new branch in your current/old repository
    • git checkout -b <new_branch_name> <old_branch_name>
  • This would give you the history and all the files from the old one. Everybody working with the repo should switch to the new branch and the old one can be kept for i-dont-know ;)
codedge
  • 4,754
  • 2
  • 22
  • 38
  • Actually, you can. Just push the old branches into the new repo, with whatever names you want. `git push u://r/l refs/heads/*:refs/heads/fromoldrepo/*` pushes everything in your current repo to the repo at u://r/l with branches named e.g. fromoldrepo/master. You can play the same games with tags. – jthill May 13 '16 at 23:52