简体   繁体   English

使用git作为svn中管理的代码库的部署机制?

[英]Using git as a deployment mechanism for a codebase managed in svn?

I'm currently looking at phpfog as a platform for a bunch of apps maintained by a small team. 我目前正在将phpfog视为由一个小团队维护的一堆应用程序的平台。 I love git, and really like the fact that they let you push to the phpfog platform over git. 我喜欢git,真的很喜欢它们让您通过git推送到phpfog平台的事实。

The apps I'm looking at hosting are all currently being version controlled in SVN. 我正在寻找托管的应用程序当前都在SVN中受版本控制。 Unfortunately, this cannot change, for lots of boring reasons I have no control over. 不幸的是,由于许多无聊的原因,我无法控制,这无法改变。

I'm trying to find a good workflow to allow continuous integration between this SVN repository and the phpfog platform. 我正在尝试找到一个好的工作流程,以允许在此SVN存储库和phpfog平台之间进行持续集成。 Essentially, the buildserver should check if there's modifications in SVN, if so then pull those down, and then do a git push over to phpfog with the changes. 本质上,构建服务器应该检查SVN中是否有修改,如果有,则将其删除,然后使用git push进行更改并git push送到phpfog。 I have a buildserver that's got both git and svn installed, but I'm running into some issues. 我有一个既安装了git又安装了svn的buildserver,但是遇到了一些问题。

The main thing I've tried so far is to do a git svn clone on the svn repo, add phpfog as a remote and then pushing to that. 到目前为止,我已经尝试过的主要方法是在svn存储库上进行git svn clone ,将phpfog添加为远程服务器,然后进行推送。 However, this fails with this: 但是,这样做失败:

$ git push phpfog master
To git@git01.phpfog.com:example.phpfogapp.com
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@git01.phpfog.com:example.phpfogapp.com'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

I think the issue is that phpfog have a git repository that I'm expected to clone out first, and yet git svn creates its own repository. 我认为问题在于phpfog有一个git存储库,我希望它首先被克隆出来,而git svn创建自己的存储库。

I tried it the other way round, cloning the empty repo from phpfog and trying to then do some sort of git svn clone into the repo, but this didn't seem to work either. 我尝试了另一种方法,从phpfog克隆了空的仓库,然后尝试将某种git svn clone到仓库中,但这似乎也不起作用。

What's the best way of doing this? 最好的方法是什么?

Im not sure if this is the best way but here is something you can try. 我不确定这是否是最好的方法,但是您可以尝试以下方法。 If you are purely deploying to PHPFog and not using that repo for version control you can try forcing the push each time. 如果您纯粹是部署到PHPFog而不是使用该仓库进行版本控制,则可以尝试每次强制执行推送。

git push --force

Consider using SubGit . 考虑使用SubGit

If you have local access to your Subversion repository, you can install SubGit into it: 如果您可以本地访问Subversion存储库,则可以在其中安装SubGit:

    $ subgit install $SVN_REPOS

After that you get $SVN_REPOS/.git Git repository and it is continuously synchronized with initial SVN repository. 之后,您将获得$ SVN_REPOS / .git Git存储库,该存储库将与初始SVN存储库连续同步。 You can work with created Git repository as usually. 您可以照常使用创建的Git存储库。

Every new revision committed into SVN automatically gets translated to appropriate Git commit and vice versa, SubGit translates every pushed Git commit into corresponding SVN revision. 提交到SVN的每个新修订都会自动转换为相应的Git提交,反之亦然,SubGit会将每个推送的Git提交转换为相应的SVN修订。

See more information at SubGit documentation . 请参阅SubGit 文档中的更多信息。

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

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