Assets directory with git-svn in WP plugin development

There are many articles which introduce workflows for git users in WordPress plugin development which requires subversion to publish into the official directory. Some articles demonstrate workflows using script programs to call svn commands for interworking between git and svn. But I like to use git commands alone for version control. And I can do plugin development with git-svn like this article or this.

One remaining thing is the ‘assets’ directory, which we use for files not required in plugin packages. For example, the assets directory can contain images and banners displayed on the plugin directory pages in WordPress.org. And because it is not under the standard directory structure of subversion, git-svn doesn’t track the assets directory.

But I’ve found a way to work with the assets directory using git-svn. Here is a sample scenario.

Assuming you’ve already cloned your subversion repository into git, you can add a new git branch to track the assets directory as following.

$ git config --add svn-remote.assets.url http://plugins.svn.wordpress.org/standard-widget-extensions/assets

$ git config --add svn-remote.assets.fetch :refs/remotes/assets

$ git svn fetch -r HEAD assets
        A       screenshot-1.png
        A       screenshot-2.png
r683132 = 4d382617f7b2163a9a07a14a786bdd46c1f6f9ea (refs/remotes/assets)

$ git checkout remotes/assets
Note: checking out 'remotes/assets'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 4d38261... tagging version 1.0

$ git checkout -b assets
Switched to a new branch 'assets'

$

Now you have a branch named ‘assets’ to track the assets directory and you can switch between master and assets branches by git-checkout. If you do ‘git svn dcommit’ on the assets branch after changing/adding files, it will update the assets directory in WordPress.org.

If you mind the ‘refname is ambiguous’ warning while checkout, please refer to this article.

I wonder how far it is from standard manners. But anyway, I can manage whole plugin directories in one git repository now.