Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have finally discovered what I need to do in order to work with SVN branches using Git. I have tried the stuff mentioned below (except where I specify) so I am fairly confident that as long as I don't do anything funny or out of line, my commits from Git to SVN should work just fine. <strong>But of course I don't take any responsibility for any problems that might occur! I am open for further comments / remarks.</strong></p> <p>Even if I don't clone the SVN repo with the standard layout, I should have remotes configured that are pointing to the relevant SVN paths on subversion.</p> <p>To clone a SVN branch (the SVN path should be pointing to the root path containing trunk, branches and tags):</p> <pre><code>git svn clone -s http://myrepo.com c:/my/local/path </code></pre> <p>If you are already have a clone of an SVN branch you need to manually add remotes to other SVN branches, check these out:</p> <ul> <li><a href="https://stackoverflow.com/questions/3239759/checkout-remote-branch-using-git-svn">Checkout remote branch using git svn</a></li> <li><a href="https://stackoverflow.com/questions/296975/how-do-i-tell-git-svn-about-a-remote-branch-created-after-i-fetched-the-repo">How do I tell git-svn about a remote branch created after I fetched the repo?</a></li> </ul> <p>What is important is that you have a local branch that is tracking the remote branch.</p> <pre><code>git checkout -b localbranch remotes/remote_branch </code></pre> <p>Now you can commit against that local branch and each time when done do this just like in trunk:</p> <pre><code>git svn fetch git svn dcommit </code></pre> <p>When you are finally done with that SVN branch and you would like to merge to trunk, you can do the following (it takes everything from that branch and rebases it into master):</p> <pre><code>git checkout master git merge localbranch git rebase -i trunk (just save the message) git svn fetch git svn dcommit </code></pre> <p>You can also just do a squash merge if you want to (if you don't want to bring all those little check-ins accross):</p> <pre><code>git merge --squash localbranch git svn fetch git svn dcommit </code></pre> <p>You might be doing a dry-run before doing a real DCOMMIT to make sure everything is fine (including the destination).</p> <pre><code>git svn dcommit -dry-run </code></pre> <p>However, if you anticipate merge conflicts (this is what I read on the web but I haven't tried it which I'm just mentioning) do the following before the <code>git checkout master</code> line shown above. This is a local branch that doesn't track the remote branch which should be used to tackle merge conflicts and stuff. Whether this is necessary is another story.</p> <pre><code>git checkout -b merge_work master git merge localbranch git checkout master git rebase merge_work </code></pre> <p>I'm writing this down for myself and for other people who might want to try this in the future.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload