惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - Mr__BRIGHT

Jupyter Notebook导入自定义模块时ImportError Pandas数据处理(2): 数据透视表,行转列、列转行、以及一行生成多行 Pandas数据处理(1): 基础方法整理 Win10-PowerShell使用conda activate激活环境无效问题及常用Conda操作 Spring AOP动态代理实现,解决Spring Boot中无法正常启用JDK动态代理的问题 Golang 如何统一处理HTTP请求中的异常捕获 CentOS常用的文件操作命令 win10周年更新后程序各种卡死,进程无法结束怎么破? GIT分支管理模型 - Mr__BRIGHT - 博客园 CentOS访问Windows共享文件夹的方法 GIT FLOW 时序图 - Mr__BRIGHT Hyper-v虚拟机文件VHDX与VHD的格式转换 CentOS详解top命令各个数据的含义 CentOS网络配置 git svn clone时间估算 .NET 4.5+项目迁移.NET Core的问题记录 老毛桃u盘装系统制作工具 一位39岁程序员的困惑:知道得越多编程越慢怎么办? 程序员的回归式进化
使用git svn clone迁移svn仓库(保留提交记录)
Mr__BRIGHT · 2016-09-30 · via 博客园 - Mr__BRIGHT

使用git svn clone迁移svn仓库

clone命令可以指定很多参数,主要用到这些,你也可以使用git svn help查看完整的参数列表。

 git svn clone https://172.16.0.241:8443/svn/xxx/ -r 76896:HEAD --no-metadata --authors-file=svnuser.text --trunk=svnproject --branches=svnbranch yourGitProject
  1. r指定起止版本号。
  2. no-metadata阻止git导出SVN包含的一些无用信息。
  3. authors-file必须指定svn帐号在git中的映射。
  4. trunk指定导出仓库的主干项目路径。
  5. branches指定svn的分支项目路径。

注意:clone命令需要管理员权限,否则会遇到下面的异常:

 couldn't truncate file .... at line 1393. 

你要做的就是右键使用管理员身份运行CMD,然后使用fatch继续执行导出。

 git svn fatch -r 76896:HEAD --authors-file=svnuser.text

当然这并不是唯一的坑,你还有可能会遇到下边的错误:

 0 [main] perl 24432 cygwin_exception::open_stackdumpfile: Dumping stack trace to perl.exe.stackdump
 fatal: malformed index info 100644 362f1c18ceed5d593eb021432545685283a93 

要解决这个问题,请打开隐藏项目找到.git/config文件,文件大概长这个样子:

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
	hideDotFiles = dotGitOnly
	longpaths = true
[svn-remote "svn"]
...

重要的就是longpaths = true这一句,然后fatch继续。
接下来的就是等待,如果你的svn库比较大,像我要导出2w+的commit,会花费相当长的时间。
so, just do it!

然然然后。。。

fetch之后通过git log你会发现看不到新的log,这是因为fetch之后并不会自动将代码合并到当前master,我们查看一下所有的分支

$ git branch -a

* master
  remotes/origin/trunk

可以看到有一个远程分支,这个就是SVN产生的分支,查看一下log

git log remotes/origin/trunk

LOG中显示了SVN最新的提交日志,我们需要手动合并到master上,然后查看日志包含了最新的提交。

git merge remotes/origin/trunk
git log

到此迁移已经完成,接下来添加GIT远程地址,放心将代码push到GIT服务器吧。