What’s the correct way to deploy a git repo to WordPress SVN?

I’ve seen a hundred different outdated, makeshift scripts that either use git-svn or do all of the hard work behind the scenes, but I still don’t feel like I’ve found the right way to do this.

I have a local git repo that I want to deploy to my WordPress-hosted SVN repo. The ideal functionality would be that I develop locally, push to github when I’m ready, then send all of the changes I’ve made to the wordpress repo.

Read More

My remote wordpress repo would update accordingly, removing files and folders that may not longer exist due to refactoring and tagging the branches accordingly. My github repo should act as usual, tagging the incoming versions.

https://github.com/deanc/wordpress-plugin-git-svn

http://danielbachhuber.com/2010/09/29/how-to-properly-use-git-with-wordpress-org-subversion/

Related posts

Leave a Reply

1 comment

  1. Well, there is no one good way to do this. However, here is a suggestion.

    What you can do is create a bare repository on your server, outside the public directory. This repository will push changes to your SVN repository and will be like the gate keeper for your SVN repo. Your website already runs an SVN repository.

    $ cd; mkdir site_bare.git; cd site_bare.git
    $ git --bare init
    

    You can use a shell script, something like https://github.com/deanc/wordpress-plugin-git-svn on the post-commit hook on this bare repository.

    #!/bin/sh
    
    echo
    echo "**** Pulling changes into the SVN repository [Hub's post-update hook]"
    echo
    
    cd $HOME/www || exit
    unset GIT_DIR
    
    # Change to SVN dir and commit changes
    echo "Changing directory to SVN and committing to trunk"
    cd $SVNPATH/trunk
    svn commit --username=$SVNUSER -m "$COMMITMSG"
    
    # Create a new tag and commit it :)
    echo "Creating new SVN tag"
    cd $SVNPATH
    svn copy trunk/ tags/$NEWVERSION1
    svn commit --username=$SVNUSER -m "Updating tag to $NEWVERSION1"
    
    # Update the version number
    echo "Updating version number for future executions"
    cd $CURRENTDIR
    echo $NEWVERSION1 > version.txt
    
    exec git-update-server-info
    

    I have taken this from https://github.com/deanc/wordpress-plugin-git-svn/blob/master/deploy.sh but you can get the git commit message directly instead of asking for one.

    On your local machine, add the bare repository as a remote and push changes to it:

    git remote add bare <bare-repository-url>
    

    How this works is, you write some code and push it to the bare repository, which using its post-update hook to push changes to the SVN repo.

    You will have to modify the code above to push changes. I have just given a reference.