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

推荐订阅源

S
Security @ Cisco Blogs
雷峰网
雷峰网
T
Threat Research - Cisco Blogs
D
Docker
The Hacker News
The Hacker News
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Project Zero
Project Zero
C
Cyber Attacks, Cyber Crime and Cyber Security
Simon Willison's Weblog
Simon Willison's Weblog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
AWS News Blog
AWS News Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
U
Unit 42
Martin Fowler
Martin Fowler
T
Threatpost
S
Schneier on Security
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
AI
AI
T
Tenable Blog
K
Kaspersky official blog
博客园 - 叶小钗
V
V2EX
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
A
Arctic Wolf
H
Heimdal Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
T
Tor Project blog
J
Java Code Geeks
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
B
Blog
P
Proofpoint News Feed
爱范儿
爱范儿
WordPress大学
WordPress大学
I
InfoQ
小众软件
小众软件
月光博客
月光博客
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
Help Net Security
Help Net Security

博客园 - 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服务器吧。