星期日, 十二月 28, 2008

git-svn,爽

@ubuntu intrepid

sudo apt-get install git-svn

git svn clone https://hmisty.googlecode.com/svn/trunk/ hmisty --username qingyan123

提示输入密码时,输入googlecode上generate的密码(注意不是账号的登录密码)

### 出错啦 ###
error: More than one value for the key svn-remote.svn.fetch: :refs/remotes/git-svn

解决:删除checkout出来的目录,重新执行clone命令
### 出错啦 ###
RA layer request failed: Server sent unexpected return value (502 Bad Gateway) in response to PROPFIND request for '/svn/!svn/vcc/default' at /usr/bin/git-svn line 1493

解决:删除checkout出来的目录,重新执行clone命令
### ###

cd hmisty

git checkout -b work #建立了work分支,可以开始编码了。注意,并没有又创建一份代码拷贝哦,比较节省磁盘

编码举例:

$ cd try
$ mkdir udp
$ cd udp

$ vi udp_udp_server.c
#include

$ git add .
$ git commit -a -m 'udp try'

$ vi udp_udp_server.c
#include

int main(int argc, char ** argv)
{
printf("starting udpl udp server\n");
}

$ git diff
diff --git a/try/udp/udp_udp_server.c b/try/udp/udp_udp_server.c
index 10b222c..3c94538 100644
--- a/try/udp/udp_udp_server.c
+++ b/try/udp/udp_udp_server.c
@@ -1,2 +1,6 @@
#include

+int main(int argc, char ** argv)
+{
+ printf("starting udpl udp server\n");
+}

$ git commit -a -m 'add main function'

编码结束。

合并分支,然后提交到远程svn server:
cd ~/hmisty/
git checkout master #切换到master分支
git merge work #合并work分支的工作过来
git svn rebase #rebase
git svn dcommit #提交到svn server

确实比svn好用哈哈,也比SVK简单方便。充分彰显如下的代码开发模式:

master
\-> branch bug_001 -> fix bug_001 -> tests pass
\-> branch bug_002 -> fix bug_002 -> tests pass
\-> branch bug_003 -> fix bug_003 -> tests pass
-> merge all branches bug_001 bug_002 bug_003
-> all tests pass
-> commit

没有评论: