svn迁移到git,分支没了?
巴扎黑
巴扎黑 2017-05-02 09:23:00
0
2
581

根据progit上的文档操作的:http://git-scm.com/book/zh/v2/Git-%E4%B8%8E%E5%85%B6%E4%BB%96%E7%B3%BB%E7%BB%9F-%E8%BF%81%E7%A7%BB%E5%88%B0-Git

遇到两个问题:

为了将标签变为合适的 Git 标签,运行

 $ cp -Rf .git/refs/remotes/origin/tags/* .git/refs/tags/
 $ rm -Rf .git/refs/remotes/origin/tags

这会使原来在 remotes/origin/tags/ 里的远程分支引用变成真正的(轻量)标签。
接下来,将 refs/remotes 下剩余的引用移动为本地分支:

$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes

.git/refs/remotes 现在所有的旧分支都是真正的 Git 分支,并且所有的旧标签都是真正的 Git 标签。
最后一件要做的事情是,将你的新 Git 服务器添加为远程仓库并推送到上面。

但是执行cp的时候发现这个目录并不存在,git branch -r列出来很多原来的

$git branch -r
origin/v1.1
origin/tags/v1.1.2
origin/tags/v1.1.2@438
origin/tags/v1.2.1
origin/tags/v1.2.1@474
origin/tags/v1.2.3
origin/trunk

然而 .git/refs/remotes/origin/tags 下面并没有文件
参考http://nowing.iteye.com/blog/844608的做法,使用标准命令将branch转成tags

$ git tag tagname tags/tagname     ----用指定的分支创建一个Git标签 
$ git branch -r -d tags/tagname    ----删除指定的远程分支

最后用git push origin --allpush到git服务器,但是只有主干,没有分支
git push origin master --tags有主干和tags,但是也没有分支

最后的最后问题来了,怎么把分支也迁移上去?

巴扎黑
巴扎黑

reply all(2)
世界只因有你

After struggling for a long time, I finally solved it with svn2git
The basic idea is to convert the remote branch to the local branch, and then push
svn2git can do it directly

漂亮男人
 git svn clone http://myhost/repo -T trunk -b branches -t tags 
 #将svn仓库转为git仓库
 git remote add oscgit https://git.oschina.net/user/repo #添加remote,这个需要在页面上建立
 git push -u origin --all
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!