Main menu
WalkswithMeWordPressGit as Version Controller for WordPress Plugin Development

Git as Version Controller for WordPress Plugin Development

Git as Version Controller for WordPress Plugin Development is really simply and easy to manage your plugin from local computer to subversion. Now everybody know that Git is a trend, now every one using Git for developing and publishing applications. This has several advantage over other SVN . I’m not talking too much about Git advantage over other SVN.

The point of this article is setup an existing  WordPress plugin in your local computer and sync with WordPress subversion. For publishing WordPress plugin you should have at lease one version controller. First you required an account with wordpress.org   Once you create an account with WordPress simply submit the form. I hope you already have a developed and uploaded plugin in your hand.

Git as version controller for wordpress plugin

Git as version controller for wordpress plugin

The plugin name that is more important that name is came in WPD(WordPress plugin Directory). Ok lets check how we can begin


http://plugins.svn.wordpress.org/wwm-social-share-on-image-hover/

So next step is to download an install Git in your local machine. you should create an account with GitHub.

Then you have two options for setting the source of the plugin on your computer either you can use your local WP installation plugin folder or use a separate folder. Here I’m using separate folder bcoz I like to keep the my experimental version separately.

So Once you install your Git you will get a Git shell application open up that. and you have to initialize your Git version controller to that folder.

Suppose it is in “D:\GitHub\” move inside that folder and type


git init

then your local folder is ready for git versions. you can see .git named folder came (may be its hidden)

If you get the approved link only and its a fresh version, the you just need a revision number that you can get using below command.


git svn log http://plugins.svn.wordpress.org/wwm-social-share-on-image-hover/

The above code will return your last revision number of the plugin something like below.


r952925 | plugin-master | 2014-07-22 19:36:16 +0200 | 1 line

In your case the above code for log is unable to execute you can get the revision number from the following link . make sure you typed with your plugin name. then you can find a revision number note it somewhere.

Open your Git shell window and make sure you are in correct directory . then download all your plugin folder structure to local machine using the command.


git svn clone --no-minimize-url -s -r952925 http://plugins.svn.wordpress.org/wwm-social-share-on-image-hover/

Once you run the above command you can see a new folder created with ” wwm-social-share-on-image-hover ” in D:\GitHub\ (my path). when you open the folder you can see its empty (.git folder is there but its hidden) move Inside the folder with following codes


cd wwm-social-share-on-image-hover

Then fetch from SVN using.


git svn fetch

The above code fails then use “fetch -all”. If it is new plugin nothing will happen. then you have to rebase means loading changes from WordPress subversion. This code should execute before you update to an existing WPD plugin other wise  multiple people working on same plugin may conflict the files.


git svn rebase

Ok now you can simply commit the changes or new files to git using following command.


git commit -am 'This is my intial commit to the wp subversion'

Then submit your files / changes to the WP subversion using


git svn dcommit

It will take little bit time and once it get finished you can see all folders on WordPress subversion are correctly linked and your files properly loaded. and plugin is ready to download with updates. Also notice one thing WordPress recently changed the banner images and screen shot folder to assets. So you have to put all those things on assets folder.

For sync your asset folder use like


git checkout remotes/assets

For New release of the version you can use like the below code will create your local git tag version.


git tag v1.0.2

For Creating the tag version in WP subversion.


git svn tag 1.0.2

Make sure your latest files are there in tag folder. If you like to publish the code using GitHub simply create a repository in Git and follow the commands


git remote add origin git@github.com:jobinjose01/wwm-social-share-on-image-hover.git

then push all your changes to GitHub, with following command


git push origin --all

I don’t like to publish my codes using GitHub I just want to use Git as version controller only, So last two steps do not required. This article is inspired from one of the top article from the GitHub you can use this as a further reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

FacebookTwitterGoogle+RSS