简体   繁体   中英

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. I love git, and really like the fact that they let you push to the phpfog platform over git.

The apps I'm looking at hosting are all currently being version controlled in 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. 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. I have a buildserver that's got both git and svn installed, but I'm running into some issues.

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. 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.

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.

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.

git push --force

Consider using SubGit .

If you have local access to your Subversion repository, you can install SubGit into it:

    $ subgit install $SVN_REPOS

After that you get $SVN_REPOS/.git Git repository and it is continuously synchronized with initial SVN repository. You can work with created Git repository as usually.

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.

See more information at SubGit documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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