在svn结帐中使用git? (没有git-svn) [英] Using git within an svn checkout? (without git-svn)

查看:90
本文介绍了在svn结帐中使用git? (没有git-svn)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一些搜索,但找不到这个问题的答案。道歉,如果它是重复的。



我想知道是否有任何问题初始化 git 回购(用于本地使用)在现有的 svn 结帐中使用,而不使用使用 git-svn



以下是我的方案:


  • 我的团队使用 svn 并且不熟悉 git

  • 我还在学习 GIT中;我不是很熟悉它,因为我与 svn

  • 我想利用功能强大的< > git (像分支,存储等)。

  • 我不想学习 code> git-svn 在这个时候(尽管我计划在未来)。
  • 我将使用 svn 客户端专门与存储库交互。 (所以我清楚地理解了我在 svn 方面做了什么,并且没有发生任何奇怪的交互)。


我认为我总是会从 svn update 和 commit 从< git master分支。当我使用功能时,我会将它合并到master中。



有没有人试过这个?有什么讨厌的缺点或副作用?提示?

解决方案

TL; DR:是的,您可以,但仅仅学习 git- svn



我试过了。你遇到的主要问题是将 svn up 操作转换为Git提交。有两种方法我见过:


  1. 添加您的 .svn 文件夹到 .gitignore ,所以你从来没有Git跟踪你的Subversion元数据。这意味着你有Subversion和Git分别跟踪你的工作副本,所以任何一个操作都需要类似的操作。



    除非你仔细考虑如何您将使用存储库,使用Subversion合并,分支机构和交换机非常舒服,并且确保仔细使用这些存储库以配合Git使用的存储库,您将失去大部分优点Git的分支模型。

  2. 使用Git跟踪您的 .svn 文件夹。这意味着如果你做了一个 svn up 和一个 git commit ,然后检出一个旧的Git这意味着你可以更容易地使用Git的分支功能,但是让Git跟踪Subversion元数据还有很多其他的问题。主要的一个(至少在Subversion 1.6中,我不知道大约1.7)是 .svn 目录中的空文件夹很重要,但Git不会跟踪空文件夹,所以它们将被删除而不会有任何警告。 给了我Git和Subversion所有最糟糕的一点,而且几乎没有什么优势,并且意味着所有的操作都需要两次完成。

    使用方法2有一段时间运气更好,但他写了一大堆帮手脚本让他这样做。特别是,他的脚本可以浏览工作副本并修复需要空文件夹添加的任何 .svn 目录。建立起来需要很多工作,但意味着他至少可以使用Git的大部分功能。不幸的是,我无法访问有问题的脚本。



    使用 git-svn 一段时间,即使作为Git初学者,我也可以证明它比这两个选项中的任何一个都更容易。我建议保留一个Subversion的工作副本,当你需要做些什么现在时,并没有时间去检查使用Git做到这一点的最佳方式,或者在 git-svn 太有限了,无法执行您所需要的操作。对于 git-svn ,我认为学习曲线并不比常规Git困难得多,特别是因为您不需要学习任何有关使用一个远程Git仓库。


    I did a number of searches, but couldn't find an answer to this question. Apologies if it is a duplicate.

    I'd like to know if there are any problems initializing a git repo (for local usage) within an existing svn checkout, but without using git-svn.

    Here's my scenario:

    • My team uses svn and is not familiar with git.
    • I'm still learning git; I'm not nearly as familiar with it as I am with svn.
    • I'd like to make use of the powerful local features of git (like branching, stashing, etc).
    • I do not want to learn git-svn at this time (though I plan to in the future).
    • I will be using an svn client exclusively to interact with the repository. (So I clearly understand what I'm doing from the svn side and don't get any strange interactions).

    I'm thinking that I would always do svn update and commit from the git master branch. As I work on features, I'd merge to and from master.

    Has anyone tried this? Are there any nasty drawbacks or side effects? Tips?

    解决方案

    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.

    这篇关于在svn结帐中使用git? (没有git-svn)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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