git svn关守存储库 [英] git svn gatekeeper repository

查看:80
本文介绍了git svn关守存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在已经使用git很久了,主要是git-svn。现在我想说服我的同事们从svn切换到git。但不幸的是,前提条件是svn知识库保持相当长的一段时间。所以我搜索了一个解决方案,并提出了这本书:



Jon Loeliger的使用Git进行版本控制。我买了它,它是非常好的,但我不完全了解设置git svn关守回购指南。


在章节16,他描述了一个
的情况,其中有一个
的Subversion版本库,并且至少有
的两个用户想要使用
Git。他提出了一个
关守git仓库,它是
唯一的颠覆界面。
在git svn克隆Subversion
repo(带--prefix = svn /)之后,所有
分支被推到一个纯粹的
仓库(git push ../svn -bare.git
'refs / remotes / svn / :refs / heads / svn / ',
和其他git用户被告知克隆
这个回购,现在它包含所有svn遥控器的本地
分支。


这部分工作正常,我想我完全理解它。我没有得到下一个部分:

如果一个克隆裸仓库的开发人员将他的repo变回推到裸仓库,然后我在裸露的仓库回购svn,用户推送的提交失败的原因很多,因为git-svn创建的替换提交。或者我错了吗?这是如何工作的?



书说


然后,要合并回Subversion,在
守门员回购中,您可以做

git checkout svn / trunk(或其他
分支 - 这是签出一个
分离的头,因为svn / trunk是一个
远程)
git合并--no-ff新特性
git svn dcommit


如何在裸仓库中检出分支?我不认为这可行


这会导致
分离头上的合并提交,然后修改后的
commit(在git-svn-id行添加
后)被放在真实的svn / trunk
分支上。


真正的svn / trunk是什么意思?


对分离的
头的提交是比冗余更糟糕的,使用
作为最后的
导致冲突,因此,忘记
关于该提交。如果你还没有把
放在一个分支上,
更容易忘记(Jon
Loeliger)。




我有点困惑。有人对创建git svn关守回购有更好的解释吗?我已经搜索了网站和这个网站,但我还没有发现任何看起来适合我的东西。



我很厌烦浪费那么多次svn分支和合并,当与我的同事合作。

解决方案


如何检出裸仓库中的分支?我不认为这有效


是的,您只需克隆裸回购本地,在这个过程中做一个非裸回购,你可以在那里结帐/创建(再次本地)尽可能多的分支。



裸机回购需要作为上游回购推动到哪里。 (请参阅 git push 仅适用于裸仓库?)



但为了推动任何事情,也就是让其他开发人员将他们在非svn分支上的更改推回到看门人回购,表示其他开发人员必须首先克隆该裸回购,对本地副本进行所有相关修改,然后推回裸回购。

另外,您可以在裸回购上设置一些挂钩为了验证您的推送:请参阅
钩子for git-svn



然后到 dcommit ,网守还克隆网守回购,他/她将从此回购:


  • 检出与svn相关的远程分支(' svn '是远程回购的名称),如' svn / trunk '例如

  • 合并该未命名分支中的相关更改

  • git-svn dcommit



回顾:


  • 开发人员克服了网守回购在自己的分支中记录他们的变化(他们可以推回去,因为网守回购是一个裸机)

  • 负责推回实际SVN回购的负责人还克隆了这个关守回购,以便选择需要合并到SVT分支的专门与SVN绑定的东西(请参阅克服git svn警告)。


I have beem using git for quite some time now, mainly git-svn. Now I want to convince my colleagues to switch from svn to git. But unfortunaly the precondition is that the svn repository keeps on living quite some time. So I searched for an solution and came up with the book:

Jon Loeliger's "Version Control with Git". I bought it and it is really good but I don't fully understand the guide to set up a git svn gatekeeper repo.

In Chapter 16, he describes a situation in which there is a Subversion repository, and at least a couple users that want to be using Git. He proposes a single "gatekeeper" git repository which is the only interface to subversion. After git svn cloneing the subversion repo (with --prefix=svn/), all the branches are then pushed to a bare repository (git push ../svn-bare.git 'refs/remotes/svn/:refs/heads/svn/', and other git users are told to clone this repo, which now contains local branches of all the svn remotes.

This part works and I think I fully understand it. But I don't get the next part:

If a developer that clones the bare repository pushes changes back from his repo to the bare repository and then I dcommit this in the bare repo to svn, the commits the user pushed are lost for good reason because of the replaced commits git-svn creates. Or am I wrong? How does this work?

The book says

Then, to merge back to subversion, in the gatekeeper repo, you do

git checkout svn/trunk (or other branch - this is checking out a detached head as svn/trunk is a remote) git merge --no-ff new-feature git svn dcommit

How can I checkout a branch in a bare repository? I don't think this works

This results in a merge commit on a detached head, and then the modified commit (after the git-svn-id line is added) is put on the real svn/trunk branch.

What is meant by real svn/trunk ?

The commit on the detached head is "worse than redundant. Using it for anything else eventually results in conflicts. So, just forget about that commit. If you haven't put it on a branch in the first place, it's that much easier to forget" (Jon Loeliger).

I'm a little confused. Has someone a better explanation for creating a git svn gatekeeper repo? I have searched the web and this site but I haven't found anything that seems suitable for me.

I'm so tired of wasting so many time with svn branching and merging, when collaborating with my colleagues.

解决方案

How can I checkout a branch in bare repository? I don't think this works

Yes it does: you simply clone the bare repo locally, making a non-bare repo in the process, where you can checkout/create (again locally) as many branch as you want.

A bare repo is needed as an upstream repo where to push to. (see "git push only for bare repositories?")

But in order to push anything to it, i.e for the other developers to push their changes in non-svn branches back to the gatekeeper repo, said other developer has to clone that bare repo first, make all the relevant modifications to the local copy, and push back to the bare repo.
Plus, you can setup some hook on that bare repo in order to validate your push: see "Hooks for git-svn".

Then to dcommit, the gatekeeper also clone that gatekeeper repo, from which he/she will:

  • checkout a remote branch related to svn ('svn' being the name of a remote repo), like 'svn/trunk' for instance
  • merge the relevant change in that unnamed branch
  • git-svn dcommit

So to recap:

  • the developer clone that gatekeeper repo to record their changes in their own branch (that they can push back, since the gatekeeper repo is a bare one)
  • the person in charge of pushing back to the actual SVN repo also clone that gatekeeper repo in order to choose what needs to be merge to a Git branch specifically tied to SVN (see for instance "Overcome git svn caveats").

这篇关于git svn关守存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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