You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将BitBucket仓库迁移至cPanel Git:保留历史并切断原关联

可以实现你的需求,操作方法如下

完全可以做到保留仓库完整历史记录,且彻底断开与原BitBucket仓库的关联。你之前看到的branch 'master' set up to track 'origin/master'提示无需担忧——只要你把origin远程地址替换成cPanel的仓库地址,这个跟踪关系是针对新仓库的,和原BitBucket仓库没有任何关联。

具体操作步骤

情况1:还没有本地仓库,从头开始迁移

  • 克隆BitBucket仓库的完整镜像(包含所有分支、标签和历史记录):
    git clone --mirror https://bitbucket.org/your-username/your-repo.git
    
  • 进入克隆后的仓库目录:
    cd your-repo.git
    
  • 移除原BitBucket的远程关联:
    git remote remove origin
    
  • 添加cPanel Git服务的远程仓库地址(先在cPanel中创建好Git仓库,获取对应的远程URL):
    git remote add origin ssh://your-cpanel-username@your-domain.com/home/your-cpanel-username/repos/your-repo.git
    
  • 推送所有内容到cPanel仓库(确保所有分支、标签和历史都同步过去):
    git push --mirror origin
    

情况2:已经有本地仓库,直接迁移

  • 先拉取原仓库的最新内容,确保本地历史完整:
    git fetch --all
    
  • 移除原BitBucket的远程关联:
    git remote remove origin
    
  • 添加cPanel的远程仓库地址:
    git remote add origin cpanel-repo-url
    
  • 推送所有分支和标签到cPanel仓库:
    git push --all origin
    git push --tags origin
    
    或者用一条命令一次性推送所有内容:
    git push --mirror origin
    

关于你之前的担忧

你执行git push -u origin master后看到的提示,只是Git在设置本地master分支跟踪当前origin(也就是你指定的cPanel仓库)的master分支,这是正常的跟踪配置,和原BitBucket仓库没有任何联系。只要你已经替换了origin的地址,就完全不用担心和原仓库有残留关联。

内容的提问来源于stack exchange,提问作者Wannabe-Coder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 21:07:42