[英]How do I migrate a flat svn repo to git repo
I have a flat svn repository which looks like: 我有一个平坦的svn存储库,看起来像:
my_repo/
├── file1.c
├── file2.c
├── file3.c
└── README
This repo has no branches, or tags and all I am trying to do is convert it to a git repository and maintain the commit history. 这个repo没有分支或标签,我想要做的就是将它转换为git存储库并维护提交历史记录。
I have tried: 我试过了:
git svn clone --trunk=/ -A users.txt svn+ssh://user@svn.example.com/projects/my_repo dest_dir
Which I assumed would work, however, when I navigate into dest_dir
and perform git svn fetch
, it doesn't seem to fetch anything. 然而,当我导航到
dest_dir
并执行git svn fetch
,我认为它可以工作,它似乎不会取任何东西。 Using git log
yields: 使用
git log
产生:
fatal: bad default revision 'HEAD'
If I use svn checkout svn+ssh://user@svn.example.com/projects/my_repo
it returns: 如果我使用
svn checkout svn+ssh://user@svn.example.com/projects/my_repo
它会返回:
A my_repo/file1.c
A my_repo/file2.c
A my_repo/file3.c
A my_repo/README
Checked out revision 57.
So the repository is alive and accessible. 因此存储库是活的并且可访问。
I have tried various tools including subgit
which was giving me this error: svn: E170003: 'stat' not implemented
and I think this is because the server hosting the repository is using an old version of subversion. 我尝试了各种工具,包括
subgit
,它给了我这个错误: svn: E170003: 'stat' not implemented
,我认为这是因为托管存储库的服务器使用旧版本的subversion。 I have no control over the server so cannot perform an update. 我无法控制服务器,因此无法执行更新。
I have also tried using the svn2git
, using the command 我也尝试使用
svn2git
,使用该命令
svn2git svn+ssh://user@svn.example.com/projects/my_repo --rootistrunk -authors users.txt --verbose
but this was giving me another error: 但这给了我另一个错误:
E: 'svn+ssh:/user@svn.example.com/projects/my_repo' is not a complete URL and a separate URL is not specified command failed
This stumped me, and I've no idea why it's not working. 这让我很难过,我不知道为什么它不起作用。 Basically I was wondering how I go about turning my svn repo into a git repo while maintaining the history.
基本上我想知道如何在保持历史的同时将我的svn repo变成一个git repo。 Hope someone can help me out, or point me in the right direction.
希望有人可以帮助我,或指出我正确的方向。 Never realised it would be so difficult to transfer this simple repo to git!
从来没有意识到将这个简单的回购转移到git会很困难!
Thanks 谢谢
The problem is with svn2git
's --rootistrunk
argument. 问题在于
svn2git
的--rootistrunk
参数。 Instead of that, try this: 而不是那样,试试这个:
svn2git svn+ssh://user@svn.example.com/projects/my_repo --trunk / --notags --nobranches --authors users.txt --verbose
I had the same problem. 我有同样的问题。 Not standard svn repository: no trunk, no tag, no brunch.
不是标准的svn存储库:没有主干,没有标签,没有早午餐。 I checked all possible options of svn2git but didn't have success.
我检查了svn2git的所有可能选项,但没有成功。 As svn2git is just ruby wrapper for git svn, I tried directly git svn and it was ok.
因为svn2git只是git svn的ruby包装器,所以我直接尝试了git svn并且没关系。 Here is what I have done.
这就是我所做的。
Init empty git dir and give svn repository path and the relative paths of trunk, tags and brunches. 初始化空git dir并给出svn存储库路径以及trunk,tags和brunches的相对路径。 In my case it is / as I don't have any of those.
在我的情况下它是/因为我没有任何这些。
1. git svn init http://svnmydomain.com/urlpart/projectname --trunk=/ --tags=/ --branches=/
If svn repo is password protected you will have to supply username and password arguments to the command above but in most cases it won't work as it's a little bit buggy. 如果svn repo受密码保护,你将不得不为上面的命令提供用户名和密码参数,但在大多数情况下它不会起作用,因为它有点儿麻烦。 Instead svn checkout in the current folder.
而是在当前文件夹中svn checkout。 git svn will use svn cash and won't ask you for password.
git svn将使用svn现金,不会要求您输入密码。
Check that git config is ok. 检查git config是否正常。 Type
类型
2. git config --list
You should see this: 你应该看到这个:
svn-remote.svn.url=http://svnmydomain.com/urlpart
svn-remote.svn.fetch=urlpart/projectname:refs/remotes/origin/trunk
svn-remote.svn.branches=urlpart/projectname/*:refs/remotes/origin/*
svn-remote.svn.tags=urlpart/projectname/*:refs/remotes/origin/tags/*
If git config is not correct, fix it manually by executing 如果git config不正确,请通过执行手动修复它
git config <key> <value>
Now when git config is ok you should fetch data from svn and push it to git server 现在当git config正常时你应该从svn获取数据并将其推送到git服务器
3. git svn fetch
4. git remote add origin git@gitdomain:url/gitproject.git
5. git add .
6. git commit -m "merge from svn"
7. git push origin master
If some people continue to work in svn, you will need to synch svn with git constantly. 如果有些人继续在svn中工作,你需要不断地与git同步svn。 To do it type:
要这样做:
8. git svn rebase
9. git push origin master
Hit same issue with an old 'flat' SVN repo, following worked with git v2.20.1: (following recipe on http://www.sailmaker.co.uk/blog/2013/05/05/migrating-from-svn-to-git-preserving-branches-and-tags-3/ ) 使用git v2.20.1进行了一次旧的“扁平”SVN回购同样的问题:(关于http://www.sailmaker.co.uk/blog/2013/05/05/migrating-from-svn-上的食谱to-git-preserving-branches-and-tags-3 / )
git svn init <SVN https URL> --stdlayout --prefix=svn/ -T /
git svn fetch --all
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.