1. 程式人生 > >git-svn 常用功能示例

git-svn 常用功能示例

在提交/簽入(commit/check in)過程中,發生了合併衝突(CONFLICT)時的基本動作。

1$ vi debian/changelog
   ...
2$ git-commit -a -m "釋出一個新版本"
Created commit 934b74c: 釋出一個新版本
 1 files changed, 6 insertions(+), 0 deletions(-)
3$ git-svn rebase
    M   debian/changelog
 r11 = ae2199620a1e66130e12d03bd48a66c8edddc195 (git-svn)
First, rewinding head to replay your work on top of it...
HEAD is now at ae21996... New Upstream Released
Applying 釋出一個新版本
error: patch failed: debian/changelog:1
 error: debian/changelog: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merged debian/changelog
CONFLICT (content): Merge conflict in debian/changelog
 Failed to merge in the changes.
Patch failed at 0001.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
 To restore the original branch and stop rebasing run "git rebase --abort".

rebase refs/remotes/git-svn: command returned error: 1
4$ vi debian/changelog
   ...
5$ git-commit -a -m "衝突解決後釋出的最新版本"
 Created commit b899d8b: 衝突解決後釋出的最新版本
 1 files changed, 2 insertions(+), 1 deletions(-)
6$ rm -rf .dotest
7$ git-svn rebase
Current branch HEAD is up to date.
8$ git-svn dcommit
Committing to 
https://virtual.googlecode.com/svn/trunk
... M debian/changelog Committed r12 M debian/changelog r12 = cc5b21aaf77a2952b4a3fa74a80cbdd826f28d92 (git-svn) No changes between current HEAD and refs/remotes/git-svn Resetting to the latest refs/remotes/git-svn

將平日修改的檔案(1),提交到本地 git 倉庫(2)。在提交至 svn 倉庫前,先獲取 svn 倉庫的最新資料(3)。此時發現 debian/changelog 檔案在 svn 倉庫中已被更新,由於我 們平日也對 debian/changelog 檔案作過修改,這就導致該檔案出現了合併衝突。手工修 改該檔案解決衝突(4),然後重新提交至本地 git 倉庫(5)。準備重新提交至 svn 倉庫 (8),保險起見,我們再一次獲取 svn 倉庫的最新資料(7),為此要先刪除因剛才(3)操作 失敗帶來的臨時目錄 .dotest(6)。(或許存在更好的解決 .dotest 目錄的方法。)