{ yeah : 必须哒 } No place to place should record our youth?

27Jan/110

[转]git svn实战

我之前写了几个wordpress插件,比如inline-javascript, code-prettify。这些插件都托管在wordpress.org提供的svn服务器上,但是我实在太喜欢在git下活动了,因此动了点心思,想把插件代码传到github上,开发完之后利用git-svn传到wordpress的svn服务上。

 

照着这个思路,捋起袖子就开干了。

用git-svn抓取插件代码

 

wordpress的插件svn库大且缓慢,如果直接用git-svn去clone代码,一定会慢死,所以我按照以前的笔记,用git从大型svn快速clone代码。

 

以code-prettify插件为例,首先需要读取这个插件创建时的版本号

 

svn log http://svn.wp-plugins.org/code-prettify|tail -4|head -1

 

得到了如下信息,获得一个版本号 318479

 

r318479 | plugin-master | 2010-12-03 20:12:29 +0800 (五, 03 12 2010) | 1 line

 

开始clone代码

 

git svn clone -s --prefix=svn/ -r318479:HEAD http://svn.wp-plugins.org/code-prettify

 

设置git仓库

 

首先把代码传了一份到github: https://github.com/volca/code-prettify

 

然后操作本地git仓库

 

git branch -m svn

git remote add origin git@github.com:volca/code-prettify.git

git checkout master

 

本地svn分支对应svn的远程仓库,本地master分支对应github的远程仓库

Happy time

 

现在可以按照平常的习惯在git下更改代码,然后用git push到github上。

 

如果需要更新代码到svn上,按这个流程操作就可以了:

 

git checkout svn

git merge master

git svn dcommit

 

如果需要发布wordpress插件的新版本,这个在svn里就是一个打tag的过程,用git-svn操作非常简单,下面的例子表示发布code-prettify插件的0.3版本:

 

git svn tag 0.3

 

[转自:http://www.ooso.net/archives/576]

Posted by alacner

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.