4

我进行了多次搜索,但找不到这个问题的答案。抱歉,如果它是重复的。

我想知道git在现有svn结帐中初始化存储库(供本地使用)是否有任何问题,但使用git-svn.

这是我的场景:

  • 我的团队使用svn但不熟悉git.
  • 我还在学习git;我对它的熟悉程度不如我对它的熟悉程度svn
  • 我想利用强大的本地特性git(如分支、存储等)。
  • 我现在不想学习git-svn(尽管我计划在未来学习)。
  • 我将svn专门使用客户端与存储库进行交互。(所以我从侧面清楚地了解我在做什么,svn并且没有得到任何奇怪的交互)。

我在想我会一直svn updatecommitgit分支做。当我处理功能时,我会与 master 合并。

有没有人试过这个?是否有任何令人讨厌的缺点或副作用?尖端?

4

2 回答 2

5

TL;DR: Yes you can, but it's harder work than just learning git-svn.

I've tried it. The main problem you have is converting svn up operations to Git commits. There are two approaches I've seen:

  1. Add your .svn folder to .gitignore, so you never have Git tracking your Subversion metadata. This means you have Subversion and Git separately tracking your working copy, so any operation on one requires a similar operation on the other.

    Unless you put a lot of thought into how you're going to use the repository, are very comfortable using Subversion merges, branches and switches, and make sure to use those carefully to match up what you're doing with the repository with Git, you'll lose most of the advantages of Git's branching model.

  2. Track your .svn folder with Git. This means that if, for example, you did an svn up and a git commit, then checked out an old Git commit, the Subversion metadata would match up correctly.

    This means you can more easily use Git's branching features, but there's a host of other problems with having Git track Subversion metadata. The primary one (at least for Subversion 1.6, I don't know about 1.7) is that empty folders in a .svn directory are significant, but Git doesn't track empty folders, so they'll be deleted without warning.

I used method 1 for a little while, but found it gave me all the worst bits of both Git and Subversion, with very little advantage, and meant everything operation needed to be done twice to get anything done.

A colleague of mine used method 2 for some time with more luck, but he wrote a whole bunch of helper scripts to enable him to do so. In particular, his scripts would spin through the working copy and fix up any .svn directories that needed empty folders adding. It was a lot of work to set up, but meant he could at least use most of the features of Git. Sadly, I don't have access to the scripts in question.

Having used git-svn for some time, I can vouch for it being easier than either of these options, even as a Git beginner. I'd recommend keeping a Subversion working copy around for the occasions when you need to do something now and don't have time to check the best way to do it with Git, or for the occasions where git-svn is too limited to do what you need it to do. The learning curve for git-svn is, I'd say, not much more difficult than that for regular Git, particularly as you don't need to learn anything about working with a remote Git repository.

于 2012-11-15T22:22:35.607 回答
1
于 2012-11-15T18:44:25.027 回答