xcode 将 git 与 svn 一起使用的好习惯

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5294516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:29:04  来源:igfitidea点击:

Good practice to use git together with svn

xcodesvngitgit-svnxcode4

提问by Forrest

Subversion was popular several years ago, now git is becoming popular and more and more people want to replace Subversion with git.

Subversion 几年前流行,现在 git 越来越流行,越来越多的人想用 git 替换 Subversion。

Problem is that a lot projects were based on Subversion. So question is how to use git together with Subversion. Do not replace svn completely, and use git.

问题是很多项目都是基于 Subversion 的。所以问题是如何将 git 与 Subversion 一起使用。不要完全替换 svn,而使用 git。

The simplest way I can figure out is to create git based on the Subversion branch code you have already checked out. Then use git to control locally. After modifications, submit to local git server, then check out to remote server with Subversion. Subversion is just like container to contain git.

我能想到的最简单的方法是根据您已经签出的 Subversion 分支代码创建 git。然后在本地使用git控制。修改后提交到本地git服务器,然后用Subversion签出到远程服务器。Subversion 就像包含 git 的容器。

BTW, I am coding with xcode 3.x , try xcode 4 before, but disappointed. ( Xcode 4 has come out now, but no retry yet)

顺便说一句,我正在使用 xcode 3.x 进行编码,之前尝试过 xcode 4,但很失望。(Xcode 4 已经出来了,但是还没有重试)

How do you think ? Or any better choices ?

你怎么想 ?或者有什么更好的选择?

Thanks

谢谢

采纳答案by VonC

Subversion is just like container to contain git

Subversion 就像包含 git 的容器

Be sure to read the CAVEATS section coming with git-svn:

请务必阅读git-svn附带的 CAVEATS 部分:

CAVEATS

警告

For the sake of simplicity and interoperating with a less-capable system (SVN), it is recommended that all git svnusers clone, fetchand dcommitdirectly from the SVN server, and avoid all git clone/pull/merge/push operations between git repositories and branches.
The recommended method of exchanging code between git branches and users is git format-patchand git am, or just 'dcommit'ing to the SVN repository.

Running git mergeor git pullis NOT recommended on a branch you plan to dcommitfrom.
Subversion does not represent merges in any reasonable or useful fashion; so users using Subversion cannot see any merges you've made. Furthermore, if you merge or pull from a git branch that is a mirror of an SVN branch, dcommitmay commit to the wrong branch.

为简单起见,用一个能力较少的系统(SVN)互操作的缘故,建议所有的git svn用户clonefetchdcommit直接从SVN服务器,并避免git仓库和分支之间的所有GIT中克隆/拉/合并/推操作。
在 git 分支和用户之间交换代码的推荐方法是 gitformat-patchgit am,或者只是“提交”到 SVN 存储库。

在您计划从的分支上运行git mergegit pull不推荐dcommit
Subversion 不代表以任何合理或有用的方式进行合并;所以使用 Subversion 的用户看不到您所做的任何合并。此外,如果您从作为 SVN 分支镜像的 git 分支合并或拉取,则dcommit可能会提交到错误的分支。

So you can adopt any merge and publicationworkflow with Git, as long as you leave the SVN branches you mirror alone (in term of merges or rebases).

因此,您可以通过Git采用任何合并和发布工作流程,只要您单独保留镜像的 SVN 分支(在合并或变基方面)。

回答by Thomas Ferris Nicolaisen

I've created a collection of how-to's and screencasts on how to use git-svn here:

我在此处创建了有关如何使用 git-svn 的操作方法和截屏视频的集合:

http://www.tfnico.com/presentations/git-and-subversion

http://www.tfnico.com/presentations/git-and-subversion

Among them you'll find a git-svn mirror setup. It's a bit of effort to understand and set up, but it's been working for me for nearly a year, with a fairly large SVN repository.

其中你会发现一个 git-svn 镜像设置。理解和设置有点费劲,但它已经对我来说有效了将近一年,有一个相当大的 SVN 存储库。

Update: An easy and valuable practice is to always initialize git-svn clones with the --prefixoption. I've explained why here.

更新:一个简单而有价值的做法是始终使用该--prefix选项初始化 git-svn 克隆。我已经在这里解释了原因