0

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?

  • 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 Answers1

0

Below is the commands to achieve this -

  1. clone your new repo.
  2. git checkout
  3. git remote add old_remote url-of-old-repo
  4. git fetch old_remote
  5. git merge old_remote/ --allow-unrelated-histories
  6. git remote rm old_remote