Migrating svn to git, branches are gone?
巴扎黑
巴扎黑 2017-05-02 09:23:00
0
2
625

According to the documentation on progit: http://git-scm.com/book/zh/v2/Git-与其他系统-迁移到-Git

Encountered two problems:

To change the tag to a proper Git tag, run

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

This will turn the remote branch references originally in remotes/origin/tags/ into real (lightweight) tags.
Next, move the remaining references under refs/remotes to local branches:

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

.git/refs/remotes Now all old branches are real Git branches, and all old tags are real Git tags.
The last thing to do is to add your new Git server as a remote repository and push to it.

But when executing cp, it was found that this directory does not exist. git branch -r lists many original ones

$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

However, there is no file under .git/refs/remotes/origin/tags
Referencehttp://nowing.iteye.com/blog/844608的做法,使用标准命令将branch转成tags

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

Finally, use git push origin --all to push to the git server, but there is only the trunk and no branches.
Use git push origin master --tags to have the trunk and tags, but there are no branches

The final question comes, how to migrate the branch?

巴扎黑
巴扎黑

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