簡體   English   中英

使用git-svn創建一個新的svn分支

[英]create a new svn branch with git-svn

使用git-svn和'典型'svn repo / trunk,/ branches / ...,/ tags / ...如何將本地分支推送到/ branches內的新分支?

假設我們有一個帶有空trunk/branches/tags/的骨架Subversion存儲庫:

/tmp$ git svn clone -s file:///tmp/svn-repo/ git-svn-repo
Initialized empty Git repository in /tmp/git-svn-repo/.git/
r1 = 80bdcfc0cf248b74b914a1b5f99ab89fb4e31b6c (refs/remotes/trunk)
Checked out HEAD:
  file:///tmp/svn-repo/trunk r1

/tmp$ cd git-svn-repo/

/tmp/git-svn-repo$ git svn branch my-branch
Copying file:///tmp/svn-repo/trunk at r1 to file:///tmp/svn-repo/branches/my-branch...
Found possible branch point: file:///tmp/svn-repo/trunk => file:///tmp/svn-repo/branches/my-branch, 1
Found branch parent: (refs/remotes/my-branch) 80bdcfc0cf248b74b914a1b5f99ab89fb4e31b6c
Following parent with do_switch
Successfully followed parent
r2 = 56150bbd9d3aec94972ff46d030e30ec726595ab (refs/remotes/my-branch)

下面的解釋將在同一個存儲庫的兩個視圖之間來回切換,整個存儲庫(不僅僅是trunk )的Subversion工作副本和git-svn克隆。 為清楚起見,每個shell提示符的前綴將指示當前目錄。

在svn方面,你現在會看到

/tmp/svn-repo-wc$ svn up
A    branches/my-branch
Updated to revision 2.

您還將在git端看到新分支:

/tmp/git-svn-repo$ git branch -r
  my-branch
  trunk

要提交新創建的分支,請先切換到它:

/tmp/git-svn-repo$ git reset --hard remotes/my-branch
HEAD is now at 2c9bef2 Create branch my-branch

接下來,我們將創建一個虛擬git提交

/tmp/git-svn-repo$ touch on-my-branch
/tmp/git-svn-repo$ git add on-my-branch
/tmp/git-svn-repo$ git commit -m 'First commit to my-branch'
[master b94a0eb] First commit to my-branch
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 on-my-branch

最后將它發送給Subversion:

/tmp/git-svn-repo$ git svn dcommit
Committing to file:///tmp/svn-repo/branches/my-branch ...
    A   on-my-branch
Committed r3
    A   on-my-branch
r3 = d3c5ba3e03e5cdee96f470ff4c9898eb7c523ed8 (refs/remotes/my-branch)
No changes between current HEAD and refs/remotes/my-branch
Resetting to the latest refs/remotes/my-branch

Subversion工作副本給我們確認:

/tmp/svn-repo-wc$ svn up
A    branches/my-branch/on-my-branch
Updated to revision 3.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM