I need to know the proper way to move git history from one repository to another on codebasehq.com. Situation:
mycompany.codebasehq.com/projects/OLDNAME/repositories/PROJECTNAME
mycompany.codebasehq.com/projects/NEWNAME/repositories/PROJECTNAME
. So new repo right now has only one (initial) commit with all files from old repo but no old history at all. I want to bring back history from old repo to new repo. I've read about rebase and graft here: How to rebase one Git repository onto another one? and I was able to successfully graft two repositories into one.
What I need to know is how to replace this new repo with 1 initial commit by rebased/grafted repo with all old history included. Should I delete this wrong new repo and re-create it from scratch or just push with some special flags to it?
UPD: I've tried to just push branch with full history (old+new) to mycompany.codebasehq.com/projects/NEWNAME/repositories/PROJECTNAME
as new branch named fullhistory
but got error:
bash-3.2$ git push codebasehq fullhistory
Counting objects: 104, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (74/74), done.
Writing objects: 100% (74/74), 1.74 MiB, done.
Total 74 (delta 36), reused 5 (delta 0)
fatal: unresolved deltas left after unpacking
error: unpack failed: unpack-objects abnormal exit
To git@codebasehq.com:mycompany/project/repo.git
! [remote rejected] fullhistory -> fullhistory (n/a (unpacker error))
error: failed to push some refs to 'git@codebasehq.com:mycompany/project/repo.git'
You could try the following:
git clone OLDREPO
git remote add new NEWREPO
git fetch new
Your old history should now be in master
while your new history is in new/master
git checkout new/master
git rebase -i master
This will start an interactive rebase that transplants everything from new/master
onto master
. Since you probably want to drop the first commit from your new code (the one that was a simple copy of the work at that time) you should delete the according line in the editor that will be shown to you. The rest should be set to pick
.