Andre V
Andre V

Reputation: 219

How can I transfer the commit history of a repository to another repository?

I've spent a few months working on a project. It broke, I started a new project and just transfered the files, but I would like to transfer just the commit history into the new repository/project? I am a little familiar with git. What command line codes would I need to only transfer the commit history?

Upvotes: 2

Views: 1754

Answers (2)

Andre V
Andre V

Reputation: 219

Figured it out. Simply:

  1. Go to project directory

    cd ProjectAcceptingCommitMessages
    
  2. Add project with commit history to current repository

    git remote add projectB /home/you/projectB
    git fetch projectB
    
  3. Then merge the two together, therefore giving you the commit history

    git merge projectB/master
    

Upvotes: 2

Paulo Fidalgo
Paulo Fidalgo

Reputation: 22296

Basically you want to add a new remote, so in the old project you just need to add a new remote:

$ git remote add origin git@remote-path/project.git

then run:

$ git remote -v

and you should have two remotes.

If you have the error:

fatal: remote origin already exists.

just use other name for remote:

$ git remote add new-origin git@remote-path/project.git

Upvotes: 3

Related Questions