Although GIT is everywhere, SVN still is the version control for all the themes and plugins hosted on WordPress.org. I've been playing with both SVN and GIT together recently when I need to repeat the same tasks again and again. This article is a small log of useful SVN commands when working with WordPress themes or plugins (only plugins actually, because WordPress.org doesn't allow us to work with the theme repository directly).
Making SVN and Git working in the same folder
I usually host my open source projects on Github. Most of them are WordPress plugins. In the past, I had to manage 2 folders: 1 for the Git and 1 for the SVN repo. And I just copied from Git to SVN whenever I want to release a new version on WordPress.org. It's a bad practice and takes time.
It's much easier to use the same folder for both Git and SVN. When we want to commit to Github, just
git commit and
git push. When we want to release a new version on WordPress.org, just
svn commit. Doing that is not too hard and seems easier than I thought at first.
Step 1: Ignore SVN files for Git
Create a new file
.gitignore in the folder and add the following line:
If the file already exists, just add that line to the end of the line.
This line tells Git to not track
.svn folder, which contains all the SVN info of the repo.
Step 2: Ignore Git files for SVN
Similar to the 1st step, run the following commands:
cd /path/to/folder svn pe svn:ignore .
The 2nd command will open an editor of your choice and you need to enter the following lines:
.git .gitignore .gitattributes readme.md
The first 2 lines are mandatory, while the last 2 ones are optional. If your repository doesn't have
readme.md, you can ignore them.
If you see an error saying the
SVN_EDITOR is not set, simply run
set SVN_EDITOR=notepad to set the SVN editor to Notepad. You should change this to another editor if you're using Mac or Linux.
Now you can run both Git and SVN in the same folder without any problem!
Tagging new version in SVN
If you're using TortoiseSVN, it has the tool built-in so you can use it simply by right-clicking on the folder, then select TortoiseSVN → Branch/tag...
In the new window, enter the
tags/version into the To path box. Then enter the commit message and press OK.
If you're not using Windows, then simply run the following command:
svn cp https://plugins.svn.wordpress.org/mb-custom-post-type/trunk https://plugins.svn.wordpress.org/mb-custom-post-type/tags/1.2.5 -m "Tagging version 1.2.5"
Hope these tips help you work with SVN faster for WordPress themes and plugins hosted on WordPress.org.