Working with SVN in the WordPress repository
Most developers are familiar working with git. But once you have submitted your plugin to the WordPress repository and your plugin has been approved you can not ignore the fact you will have to work with SVN.
Content of this article
- Tools used in this article
- First time adding your files
- Editing your files
- Other articles on this subject
Tools used in this article
make sure when you install tortoise, you install the command line tools feature
Setup you working folder
In this example I have made a folder to hold al mu WordPress repositories.
Open a command line application at that location.
to verify you are in that location you can use:
D:\plugins>echo %cd% D:\plugins
$ pwd /d/plugins
Now run the following command to initialize your local copy of the repository, where XXXXXX is the name of your plugin in the WordPress repository:
$ svn co https://plugins.svn.wordpress.org/XXXXXX XXXXXX-repository
At this point there is no need for a password yet as anybody is allowed to acquire a copy of your plugin. This is accassible in the browser as well and can be found using the link:
A live example of the famous WooCommerce plugin repository: link
First time adding your files
The development version of your plugin resides in the trunk folder, if this has the stable version number this is the version that will be downloaded by users. You need to setup your readme.txt accordingly. If the stable version is lower than the version in your trunk and the stable version is in the tags folder, the stable version from the tags folder will be downloaded.
$ cd XXXXXX-repository XXXXXX-repository/ $ svn add trunk/* > A trunk/XXXXXX.php > A trunk/readme.txt
This is somewhat the same as ‘git add’ so the next step is to commit your files to the WordPress repository:
XXXXXX-repository/ $ svn ci -m 'initial commit for XXXXXX' --username your_username --password your_password > Adding trunk/XXXXXX.php > Adding trunk/readme.txt > Transmitting file data . > Committed revision 1214.
Editing your files
in this example we have put the repository in a plugins folder. If we open the plugins folder with an IDE to edit the files the .idea (PHPStorm) or .project (sublime) IDE setting files will not be in the repository. So we can safely open the plugins folder with our IDE. Unlike git the substructure of /trunk, /tags and so on prevent having the repository in a live WordPress installation.
SVN can not handle it if you delete the files in trunk and past a version of your testing site plugin in the folder. Git is better in the way. You need to overwrite, or directly edit the files for it to work.
Before editing you need to be sure your local repository as up to pace with the version in the WordPress repository:
$ cd XXXXXX-repository/ XXXXXX-repository/ $ svn up > At revision 1214.
Now you can make your changes and similar to the initial commit, (check in) commit your changes:
(make sure to change the version numbers so users will be notified by the update)
XXXXXX-repository/ $ svn ci -m "new feature and new version" > Sending trunk/my-plugin.php > Sending trunk/my-plugin.php > Transmitting file data . > Committed revision 1215.
XXXXXX-repository/ $ svn add trunk/*
Push your changes
XXXXXX-repository/ $ svn ci -m "This is a commit (check in)"
Show changed files in your working folder
XXXXXX-repository/ $ svn stat
Show changes in your files
XXXXXX-repository/ $ svn diff
Copy the trunk to a stable version in tags
XXXXXX-repository/ $ svn cp trunk tags/1.1
deleting an old stable tag (or file)
XXXXXX-repository/ $ svn delete tags/1.1
Other articles on this subject
- How to use subversion – WordPress official