We are moving our code from one project to another project. But we want to retain the commit history. Please let me know if there is any way I can do this?
Asked
Active
Viewed 29 times
0
-
If you mean that you're starting a new repo with a completely new history, then the answer is, not easily. But, if your current code can be viewed of as a dependency, then why not leave it as that, and bring it into your new project as a dependency? – Tim Biegeleisen Mar 07 '19 at 13:39
-
Actually, It is just that we are moving our repo in diffrent GIT structure. I don't think that can be possible without creating new repo. – Ritesh Singh Rajput Mar 07 '19 at 13:45
-
1[See here](https://stackoverflow.com/questions/17371150/moving-git-repository-content-to-another-repository-preserving-history) for a possible solution. – Tim Biegeleisen Mar 07 '19 at 13:46
-
Thanks, it worked for me :) – Ritesh Singh Rajput Mar 07 '19 at 14:04
1 Answers
0
Below is the commands to achieve this -
- clone your new repo.
- git checkout
- git remote add old_remote url-of-old-repo
- git fetch old_remote
- git merge old_remote/ --allow-unrelated-histories
- git remote rm old_remote

Ritesh Singh Rajput
- 341
- 2
- 13