git-svn

像 subversion (svn) 這類集中式的 scm 一定要有網路連線才能 commit ,這是很討厭的一件事情,尤其是很多人都會用 notebook 工作,不見得需要長時間連結網路,或者是並沒興趣修改 svn 上的版本。這時候像老牌的 monotone 或是現在的 git 以及 Mercurial 這種分散式的版本管理系統就很好用。這陣子在改一個 project,他已經有 svn 在 googlecode 上,看來已經很久沒人 maintain. 我當然還不需要 svn write 權限,但是我仍然希望在自己 local 端有版本管理,這樣我如果幹了什麼蠢事才救得回來。

此時 git-svn 這種工具就真的很好用。基本使用方式是

# Clone a repo (like git clone):
        git-svn clone http://svn.foo.org/project/trunk
# Enter the newly cloned directory:
        cd trunk
# You should be on master branch, double-check with git-branch
        git branch
# Do some work and commit locally to git:
        git commit ...
# Something is committed to SVN, rebase your local changes against the
# latest changes in SVN:
        git-svn rebase
# Now commit your changes (that were committed previously using git) to SVN,
# as well as automatically updating your working HEAD:
        git-svn dcommit
# Append svn:ignore settings to the default git exclude file:
        git-svn show-ignore >> .git/info/exclude

日後如果我想要把修改 commit 到 upstream 去,我在這段時間的修改記錄仍然可以保留。相當有彈性的作法。

One thought on “git-svn

  1. Pingback: GIT 工作流程

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s