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?
Asked
Active
Viewed 83 times
0
-
how about starting a new branch of the old repository? – Imran Ali Apr 08 '16 at 02:42
-
Will I be able to merge the new branch into the master branch? (Sorry if my github jargon is a little off, I'm new to this) – Stephanie Fu Apr 08 '16 at 02:44
-
yes! this is a fundamental feature of git – Brandt Solovij Apr 08 '16 at 02:44
-
is the repo remote or on your local machine? if its remote, this answer may help : http://stackoverflow.com/questions/5181845/git-push-existing-repo-to-a-new-and-different-remote-repo-server – Brandt Solovij Apr 08 '16 at 02:45
-
Please be more clear about what you mean by `put into`. – merlin2011 May 13 '16 at 22:22
1 Answers
-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