Skip to content

Instantly share code, notes, and snippets.

@Page-Carbajal
Last active October 25, 2019 16:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Page-Carbajal/d6cc17736d8e020ee0fe to your computer and use it in GitHub Desktop.
Save Page-Carbajal/d6cc17736d8e020ee0fe to your computer and use it in GitHub Desktop.
Publishing a Git Repository to WordPress with SVN

From a Git Repository to WordPress SVN

Well this is kind of fun right. Specially since must of us have not used SVN for over 10 years.

Lets do this. Our objective here is to create a common codebase for both SVN and Git.

Process for empty SVN Project

Doing this is not that complicated

  1. Clone your git repo to a local path
  2. Checkout your SVN repo to the same folder
  3. Add SVN folders to git ignore
  4. Ignore .git directory with SVN
  5. Add all files to SVN trunk
  6. Commit to SVN
  7. Tag! You are it!
  8. Checkout the assets folder
  9. Add assets
#1. Clone your git repo
git clone https://github.com/octopus-digital-strategy/an-easy-skype-button
#2. Chekcout SVN
cd /path/to/copy
svn checkout http://wordpress.path.to/repository/trunk ./
# Your should get a message like this: Checked out revision 9898989893
#3. Add SVN folders assets to git ignore. I use ATOM you can use what you like better
atom .gitignore
#4. Remove .git from SVN
svn propset svn:ignore .git . 
svn propset svn:ignore .gitignore . 
#5. Add all files to SVN
svn add --force ./
#6. Commit to SVN
svn commit -m 'Initial import' --username yourusername #svn will prompt you for the password
# future commits will jut use the same credentials
svn up
#7. Make a tag
svn copy http://wordpress.path.to/your-repo/trunk http://wordpress.path.to/your-repo/tags/0.2.1 -m "Release 0.2.1"
# You should get another update message
# And... You're done!

See that was not as complicated as you tought!

Steps 8 and 9

This step is very easy. What we are going to do is checkout the assets folder from our WordPress repository. Use this folder to store your screenshots and icons. Files like

  1. screenshot-1.jpg
  2. screenshot-2.jpg
  3. screenshot-3.jpg
  4. icon-16x16.png
  5. icon-32x32.png
cd path/to/project
svn checkout http://svn.wordpress.org/path/to/project/assets 
# remember to tell SVN to ignore this folder
svn propset svn:ignore assets .
# You should see a confirmation message
svn up
# And another confirmation message 

This command will create an assets folder, add some screenshots and icons then run this commands

cd assets
svn add ./
svn commit -m 'Added new screenshots'
# You should see an update message
svn up
# You should see an update message

Moving further you have to remember to keep your main php file up to date with the correct version number, as well as update the readme.txt file to indicate whih tag is the one WordPress needs to look into.

Process to Join two repositories into a single codebase

Ok. So Now you know how to handle 2 code bases as 1. But that was easy since the SVN repo was empty.

How do you repeat this process now that you have the code on SVN and Git?

Stay tunned to learn how!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment