Our release of our Stop Web Crawlers WordPress Plug-in, is now available on the WordPress.org plug-in directory, the initial release of the code to the directory presented us with an interesting challenge of integrating tow different Source Code Version Control Repositories.
Our internally we primarily use Git and public GitHub repositories for Stop Web Crawlers plugin version control. However WordPress.org make use of Subversion to manage the release versions of plugins.
The WordPress Plug-ins Directory is a hosting site, not a listing site. We didn’t really want to switch to Subversion internally just to support all the future WordPress Plug-ins.
We wanted to make use of our Git and GitHub repositories but still only publish new versions of our plug-ins once they are ready for release to the WordPress Plug-in Directory. Fortunately, after thankfully finding Ben Lobaugh’s blog post this easy enough to implement. The following can be used as a guide to provide you with the basics for you to develop further.
Linux and Mac
We make use of Linux or Mac OSX to do all of our development, so the instructions below are most suited to these environments.
Install Git and Subversion
To ensure you have both Git and Subversion installed your system, you can simply install them using the following terminal commands.
## Install Git sudo apt-get install git ##install subversion sudo apt-get install subversion
## Install Subversion via HomeBrew on Mac brew install svn or brew install subversion
Create .gitignore and .svnignore files
You may not want to exclude some files from each of the repositories. i.e. Your eclipse build folders and README.md file from your Subversion repositories. Our bet practice is create gitignore files and subversion ignore files to exclude any files we don’t want to share.
*.log wp-config.php wp-content/advanced-cache.php wp-content/backup-db/ wp-content/backups/ wp-content/blogs.dir/ wp-content/cache/ wp-content/upgrade/ wp-content/uploads/ wp-content/wp-cache-config.php wp-content/plugins/hello.php /.htaccess /license.txt /readme.html /sitemap.xml /sitemap.xml.gz *.buildpath *.project *.settings
*.log wp-config.php wp-content/advanced-cache.php wp-content/backup-db/ wp-content/backups/ wp-content/blogs.dir/ wp-content/cache/ wp-content/upgrade/ wp-content/uploads/ wp-content/wp-cache-config.php wp-content/plugins/hello.php /.htaccess /license.txt /readme.html /sitemap.xml /sitemap.xml.gz *.buildpath *.settings *.project
The process may change a little depending on where in the Software Development Lifecyle you’re in. So for instance if you’re just starting out you may want to create your GitHub repository, or if you’re wokring off a mature GitHub repository you may just want to clone it
Create GitHub Repository
You may want initially create your GitHub repository using the initialize the Git repository on your local machine and configure the remote for you GitHub and commit and push your files.
## Initialise git in your directory git init ## add all files in your current directory git add . ## Commit all files and folders git commit -am "Some meaningful comment" ## Configure you remote GitHub Repository ## REMEMBER TO USE YOUR REPOSITORY URL!!! git remote add origin https://github.com/threenine/StopWebCrawlers.git ## Replace with yours!! ## Push all your current files git push -u origin master
Clone exisitng Git Hub Repo
Clone using SSH
git clone email@example.com:threenine/StopWebCrawlers.git
Clone using HTTPS
git clone https://github.com/threenine/StopWebCrawlers.git
When your repository cloning is complete. You will need to change directory into your working directory
Set up a Subversion tracking branch
We will create a branch that will only be used for keeping track of the changes between the two repositories. You will never carry out any software development directly on this branch. We will only be making use of Git’s merging capabilities to merge and publish our changes on this branch to our subversion repository.
git branch --no-track svnsync git svn init -s https://plugins.svn.wordpress.org/stop-web-crawlers/ --prefix=origin/ git svn fetch --log-window-size 10000 #CAUTION THIS LINE TAKES A LONG TIME TO COMPLETE git reset --hard origin/trunk
Daily Development operations
Once this is all set up, we can now continue with a daily operations, adding new features and fixing bugs etc. Once we’re ready to update the release on subversion we simply, need to merge our subversion branch and development branch.
Merge changes from subversion to Github
git checkout svnsync git svn rebase git checkout master git merge svnsync git push origin master
Merges changes from Github and publish to subversion
git checkout master git pull origin master git checkout svnsync git svn rebase git merge --no-ff master git commit git svn dcommit
A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Latest posts by Gary Woodfine (see all)
- How to run PHP Server with BrowserSync and Gulp - September 2, 2018
- How to change WordPress User Password in phpMYAdmin - July 28, 2018
- 8 Plugins you need for your WordPress Website 2018 - July 1, 2018