如何正确地将一个git存储库推到codebasehq的另一个存储库上? [英] How to properly push one git repository over another on codebasehq?

查看:88
本文介绍了如何正确地将一个git存储库推到codebasehq的另一个存储库上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道在gitbasehq.com上将git历史记录从一个存储库移动到另一个存储库的正确方法.情况:

  • 在codebasehq.com上有一个存储库,我在mycompany.codebasehq.com/projects/OLDNAME/repositories/PROJECTNAME
  • 之类的路径上称其为旧"
  • 在对旧存储库进行一些开发之后,团队意识到此存储库实际上应位于codebasehq.com上的不同位置,并仅使用旧"存储库中的文件进行了新"存储库并将其推送到mycompany.codebasehq.com/projects/NEWNAME/repositories/PROJECTNAME.因此,新存储库现在仅包含一次(初始)提交,其中包含旧存储库中的所有文件,而根本没有旧的历史记录.

我想将历史记录从旧存储库恢复到新存储库.我已经在这里阅读了有关重新设置和移植的信息:如何重新设置一个可以将Git存储库转移到另一个存储库吗?,我能够将两个存储库成功移植到一个存储库中.

我需要知道的是如何用包含所有旧历史的重新编制/移植的回购协议用1次初始提交替换此新回购协议.我应该删除此错误的新存储库并从头开始重新创建它,还是仅向其中添加一些特殊标志?

UPD:我试图将具有完整历史记录(旧+新)的分支作为名为fullhistory的新分支推送到mycompany.codebasehq.com/projects/NEWNAME/repositories/PROJECTNAME,但出现错误:

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'

解决方案

您可以尝试以下操作:

  • git clone OLDREPO
  • git remote add new NEWREPO
  • git fetch new

您的旧历史记录现在应该位于master中,而您的新历史记录应该位于new/master

  • git checkout new/master
  • git rebase -i master

这将启动一个交互式基础,该基础将所有内容从new/master移植到master.由于您可能想从新代码中删除第一次提交(当时是工作的简单副本),因此应在编辑器中删除将显示给您的相应行.其余应设置为pick.

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'

解决方案

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.

这篇关于如何正确地将一个git存储库推到codebasehq的另一个存储库上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆