将svn转换为git,如何让svn回购中的分支不仅仅是远程? [英] Converting svn to git, how to get the branches not to be just remote in the svn repo?

查看:90
本文介绍了将svn转换为git,如何让svn回购中的分支不仅仅是远程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git很陌生,我试图将一个svn仓库移到git中。我遵循下面的指南,所以现在我的服务器上有一个git repo

http://pauldowman.com/2008/07/26/how-to-convert-from-subversion-to-git/



因此,如果我做git分支git回复* master,并且如果我做了git branch -r,我会得到svn仓库中所有分支的列表。 p>

我的最后一个svn-checkins已经在其中一个分支中,但是当我做了git svn clone-stuff时,我在那个分支中提交了(它们还没有被合并到主干尚未)在我的(git)主分支中可见。我在这里错过了什么?



另外,如果我在我的开发机器上执行git clone,那么我会得到这些文件。但是如果我做了git branch -r,我只能看到master分支,而不是远程分支。

由于我们摆脱了svn-repo所有在一起,我想拥有在git-repo中的所有svn分支,以便他们可以从开发者客户端访问。



同样,我不是总数git newbie但离它不远,所以如果有什么基本的东西我在这里失踪了,请告诉我。

更新

在做了一些RTFM(man git-svn)之后,我解决了master分支中存在的第一个问题。
$ b


reset - -hard remotes / trunk


现在,trunk和master分支是一样的,接下来要弄清楚如何获得来自开发客户端的分支机构。

更新2

我通过结合上面的url和url Scott指出,所以从一开始就是这样。

I首先在服务器上创建一个空的存储库,它们保存在我们服务器上的/ usr / local / git-repos中:

  server> ; cd / usr / local / git-repos 
server> mkdir my_project.git
服务器> cd my_project.git
服务器> git init

然后我将svn-repository克隆到我的开发机器(注意,在我们的svn服务器分支目录称为分支 's'):

  dev> ; git svn clone http://< svn.server> / my_project --no-metadata -A authors.txt -t tags -b branch -T trunk my_project 

然后进行一些清理工作,以便按顺序获取标签和分支:

 设备> cp -Rf .git / refs / remotes / tags / * .git / refs / tags / 
dev> rm -Rf .git / refs / remotes / tags
dev> cp -Rf .git / refs / remotes / * .git / refs / heads /
dev> rm -Rf .git / refs / remotes

现在将我的服务器添加为远程存储库:

  dev> git remote add origin jorgen @< our_server>:/ usr / local / git-repos / my_project.git 

最后,将所有分支和标签推送到服务器:

  dev> git push origin --all 

现在你已经拥有它了,现在我可以摆脱它了svn-repo。

更新3

结帐 ebneters文章下面是一个更简单的方法...

解决方案

关于如何做一个相当不错的SVN有一个相当详细的解释导入,解释如何在这里正确地转换分支:



https://git-scm.com/book/en/v1/Git-and-Other-Systems-Migrating-to-Git



简短的回答是运行这个:

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

希望有帮助。


I'm quite new to git and I'm trying to move a svn repository to git. I followed the guide below so now I have a git repo on my server
http://pauldowman.com/2008/07/26/how-to-convert-from-subversion-to-git/

So, if I do "git branch" git replies "* master" and if I do "git branch -r" i get a list of all the branches in the svn repository.

My last svn-checkins have been in one of the branches, but when I did the "git svn clone"-stuff my commits in that branch (they have not been merged into the trunk yet) are visible in my (git) master branch. What am I missing here?

Also, if I on my development machine do "git clone " I get the files alright. But if I do "git branch -r" I can only see the master branch and not the remote branches".

Since we're getting rid of the svn-repo all together I would like to have all the svn branches in the git-repo so that they can be accessed from the developer clients.

Again, I'm not a total git newbie but not far from it. So if there is something fundamental I'm missing here please tell me.

Update
After doing some RTFM (man git-svn) I solved the first problem with branch stuff present in the master branch

reset --hard remotes/trunk

Now the trunk and the master branch are the same. Now, next is to figure out how to get the branches from the development clients.

Update 2
I got it working by combining the url above and the url that Scott pointed to. So, from the beginning.

I first created an empty repository on the server, they are kept in /usr/local/git-repos on our server:

server> cd /usr/local/git-repos
server> mkdir my_project.git
server> cd my_project.git
server> git init

Then i cloned the svn-repository to my dev-machine (note, that on our svn server the "branches" dir is called "branch" witout the 's'):

dev> git svn clone http://<svn.server>/my_project --no-metadata -A authors.txt -t tags -b branch -T trunk my_project

Then some clean-up to get the tags and branches in order:

dev> cp -Rf .git/refs/remotes/tags/* .git/refs/tags/
dev> rm -Rf .git/refs/remotes/tags
dev> cp -Rf .git/refs/remotes/* .git/refs/heads/
dev> rm -Rf .git/refs/remotes

Now add my server as a remote repository:

dev> git remote add origin jorgen@<our_server>:/usr/local/git-repos/my_project.git

Finally, push all branches and tags up to the server:

dev> git push origin --all

Phew, now there you have it, now I can get rid of that svn-repo.

Update 3
Checkout ebneters post below for an easier way of doing it...

解决方案

There is a fairly detailed explanation on how to do a pretty good SVN import that explains how to convert the branches properly here:

https://git-scm.com/book/en/v1/Git-and-Other-Systems-Migrating-to-Git

The short answer is to run this:

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

Hope that's helpful.

这篇关于将svn转换为git,如何让svn回购中的分支不仅仅是远程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆