How to properly push one git repository over another on codebasehq?

て烟熏妆下的殇ゞ 提交于 2019-12-08 03:54:36

问题


I need to know the proper way to move git history from one repository to another on codebasehq.com. Situation:

  • there is a repo on codebasehq.com which I call "old" on path like mycompany.codebasehq.com/projects/OLDNAME/repositories/PROJECTNAME
  • after some development in old repo the team realized that this repo should actually be in different location on codebasehq.com and did "new" repo with just files from "old" repo and push it to 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'

回答1:


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.



来源:https://stackoverflow.com/questions/13450131/how-to-properly-push-one-git-repository-over-another-on-codebasehq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!