1、svn 转换为 git(会提示,让你输入先前 svn 的账号与密码)
# 切换至 本地项目目录
cd /Users/jianbao/PhpStormProjects/fiisoo/ # 克隆 svn 项目,并转换为 git 项目
git svn clone svn://IP地址/projectname --no-metadata projectname2
2、添加远程 git 仓库
cd /Users/jianbao/PhpStormProjects/fiisoo/projectname2
git remote add origin git@xxx.xxx.xxx.xxx:root/projectname2.git
3、推送代码到远程 git 仓库
git push -u origin master
特别说明
当执行完 git svn clone svn://IP地址/projectname --no-metadata projectname2
命令后,会在项目的 .git/config 文件中添加 svn 远程库信息,如下所示:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[svn-remote "svn"]
noMetadata = 1
url = svn://IP地址/projectname
fetch = :refs/remotes/git-svn
[remote "origin"]
url = git@xxx.xxx.xxx.xxx:root/projectname2.git
fetch = +refs/heads/*:refs/remotes/origin/*
强烈推荐把 [svn-remote "svn"]
节点信息删除掉,留着也没啥用,碍事!
即把以下信息删除掉:
[svn-remote "svn"]
noMetadata = 1
url = svn://IP地址/projectname
fetch = :refs/remotes/git-svn
参考: