svn迁移至git 保留提交记录

  1. 生成一个authors.txt文件。这将包含您的SVN用户和Gitlab用户之间的映射: 可以跳过

    • 从现有的svn存储库中: svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
    • 否则,请按照以下格式手动创建它:

      oldSVNusername = newGitlabUsername <gitlabRegisteredEmailAddress@example.com>

  2. 创建一个临时目录初始化SVN存储库

    • mkdir temp
    • cd temp
    • git svn init --no-metadata http://username:password@example.com:81/svn/myrepository
  3. 配置git

    • git config svn.authorsfile ~/authors.txt 可以跳过
    • git config --global user.name myusername
    • git config --global user.email myusername@example.com
  4. 抓取文件并将其克隆到新的git repo中

    • git svn fetch
    • git clone . ../myrepository
    • cd ../myrepository
  5. 在gitlab中设置新的存储库,确保您的用户可以访问它。

  6. 添加一个远程gitlab存储库

    • git remote add gitlab gitlab.example.com:gitlab-group/myrepository.git
    • 也可以使用gitlib提示信息操作
    • Git 全局设置
      git config --global user.name "bo wang"
      git config --global user.email "wb2110@qq.com"
      
      创建一个新仓库
      git clone http://gitlab.xxx.com/web-ui.git
      cd web-ui
      touch README.md
      git add README.md
      git commit -m "add README"
      git push -u origin master
      推送现有文件夹
      cd existing_folder
      git init
      git remote add origin http://gitlab.xxx.com/web-ui.git
      git add .
      git commit -m "Initial commit"
      git push -u origin master
      推送现有的 Git 仓库
      cd existing_repo
      git remote rename origin old-origin
      git remote add origin http://gitlab.xxx.com/web-ui.git
      git push -u origin --all
      git push -u origin --tags
  7. 仔细检查您的配置myrepository/.git/config(尤其是URL行)

    [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = /root/temp/. fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = gitlab merge = refs/heads/master [remote "gitlab"] url = http://gitlab.example.com/gitlab-group/myrepository.git fetch = +refs/heads/*:refs/remotes/gitlab/* [user] name = myusername

  8. 将其全部推向上游

    • git push --set-upstream gitlab master

搬运from:https://stackoverflow.com/questions/35900710/svn-to-git-conversion-correct-remote-ref-must-start-with-refs-error

posted @   wolbo  阅读(215)  评论(1编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· winform 绘制太阳,地球,月球 运作规律
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示