简体   繁体   English

为什么git svn会建立新分支,我该如何解决?

[英]Why is git svn making new branches and how can I fix?

My team agreed to migrate from svn to git. 我的团队同意从svn迁移到git。 So I created a repository xxwin then I ran something similar to this: 因此,我创建了一个存储库xxwin,然后运行了类似的代码:

git svn clone --stdlayout --no-metadata --authors-file=users.txt svn://hostname/path xxwinRepository
cd xxwinRepository
git remote add origin https://bitbucket.org/xxxxx/xxwin.git
git push

It took a really long time but it seemed to work fine. 这花了很长时间,但似乎工作正常。

Then one developer said he had committed some more changes to svn since migrating. 然后一位开发商表示,自迁移以来,他对svn做出了更多更改。

Instead of restarting I thought I could just run 不用重启我以为我可以跑

git svn fetch
git push

It seems to have pushed everything to new branches. 看来一切都推到了新的分支。 Unfortunately this happened a couple of times before I realized what was happening. 不幸的是,这发生了两次,直到我意识到发生了什么。 Now we have hundreds of branches.. 现在我们有数百个分支机构。

For example we had a branch called v2_5_working in svn and now in git there are branches called origin/v2_5_working xxwin/origin/v2_5_working xxwin/xxwin/origin/v2_5_working 例如,我们在svn中有一个名为v2_5_working的分支,现在在git中有称为origin/v2_5_working分支xxwin/origin/v2_5_working xxwin/xxwin/origin/v2_5_working

Is there some way to easily merge all these branches? 有什么方法可以轻松合并所有这些分支吗? In case there is a next time is there a way to make it merge as part of the git svn fetch ? 万一下次有没有办法使其合并为git svn fetch

You used --no-metadata flag in your git svn clone command. 您在git svn clone命令中使用了--no-metadata标志。 This means that the git commits that were created do not have any link to corresponding svn commit, and git cannot know that the new commit the developer made to svn was supposed to go on top of some branch in git. 这意味着创建的git提交没有指向相应svn提交的链接,并且git无法知道开发人员对svn所做的新提交应该位于git中某个分支的顶部。

Only use --no-metadata if you plan to do a one-time conversion, not if the development continues on svn. 如果您打算进行一次转换,则仅使用--no-metadata ,而不是在svn上继续开发时,则不要使用。 Quoting the documentation : 引用文档

This gets rid of the git-svn-id: lines at the end of every commit. 这就消除了git-svn-id:每次提交结束时的行。

This option can only be used for one-shot imports as git svn will not be able to fetch again without metadata. 此选项只能用于单次导入,因为git svn如果没有元数据将无法再次获取。 Additionally, if you lose your $GIT_DIR/svn/ */.rev_map. 此外,如果您丢失了$ GIT_DIR / svn / * /。rev_map。 files, git svn will not be able to rebuild them. 文件,git svn将无法重建它们。

The git svn log command will not work on repositories using this, either. git svn log命令也不适用于使用此命令的存储库。 Using this conflicts with the useSvmProps option for (hopefully) obvious reasons. 出于明显的原因,使用此方法与useSvmProps选项冲突。

This option is NOT recommended as it makes it difficult to track down old references to SVN revision numbers in existing documentation, bug reports and archives. 不建议使用此选项,因为它会使您难以在现有文档,错误报告和存档中跟踪对SVN修订版号的旧引用。 If you plan to eventually migrate from SVN to Git and are certain about dropping SVN history, consider git-filter-branch 1 instead. 如果您打算最终从SVN迁移到Git,并且确定要删除SVN历史记录,请考虑使用git-filter-branch 1 filter-branch also allows reformatting of metadata for ease-of-reading and rewriting authorship info for non-"svn.authorsFile" users. filter-branch还允许重新格式化元数据,以易于阅读和重写非“ svn.authorsFile”用户的作者信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM