2010-03-29 7 views

risposta

7

supponga di avere un repository scheletro Subversion con vuoto trunk/, branches/ e tags/:

/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)

La spiegazione che segue passa avanti e indietro tra due viste dello stesso repository, un sovvertimento copia di lavoro l'intero repo (non solo trunk) e un clone git-svn. Per maggiore chiarezza, il prefisso di ciascun prompt della shell indicherà la directory corrente.

Sul lato svn, potrai ora vedere

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

Si vedrà anche il nuovo ramo sul lato git:

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

di impegnarsi per il ramo appena creato, prima passare ad esso:

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

Avanti, creeremo un git commit fittizio

/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

e infine inviarlo a 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

Il funzionamento copia Subversion ci dà la conferma:

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

come specificato sul http://stackoverflow.com/questions/266395/ git-svn-how-do-i-crea-un-nuovo-svn-branch-via-git ora puoi passare a un ramo svn invece di fare il reset --hard: 'git checkout -b my-local -branch remote-branch' '# edit' 'git commit' ' git svn dcommit' 'git checkout master # per lavorare di nuovo sul trunk' – jackbravo