Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>Disclaimer:</em> I generally <em>do</em> tend to run <code>git svn rebase</code> before doing a <code>git svn dcommit</code>. I usually keep my changes in another git branch, so that the rebase doesn't have any chance of failing. I use <code>git rebase master</code> in my topic branch to bring it up to date. Then I switch to the <code>master</code> branch and use <code>git merge</code> to incorporate the changes from my topic branch into <code>master</code> (this is a fast-forward due to the rebase).</p> <p>My explanation below explains why this isn't <em>mechanically</em> necessary, but I do agree that it's a good idea to do. Your changes might not cause conflicts in terms of diffs and merging, but if you <code>dcommit</code> your code without getting the latest changes from svn and reviewing their effects, you could be committing code to svn that doesn't really do the right thing.</p> <hr> <p>You don't <em>have</em> to <code>git svn rebase</code> before running <code>git svn dcommit</code>. If the modifications you want to dcommit are in files that haven't changed in svn since you last fetched changes, then git-svn won't show a conflict. In this way, you could be committing changes to an svn repository using a git repository that doesn't have all the latest changes from svn.</p> <p>Let's say I start an svn repository that contains two files, <code>foo.txt</code> and <code>bar.txt</code>. They only have a single revision so far. I do a <code>git svn clone</code> to start tracking the svn repository using git.</p> <pre> $ git log --oneline --decorate 7e72290 (git-svn, master) Initial commit. </pre> <p>You make changes to <code>foo.txt</code> and <code>git commit</code> them to your local <code>master</code> branch, so it moves ahead of <code>git-svn</code>.</p> <pre> $ git log --oneline --decorate aa70eca (master) Added a line to foo. 7e72290 (git-svn) Initial commit. </pre> <p>What you didn't realize is that your friend already committed changes to <code>bar.txt</code>as svn revision 2.</p> <p>Now when you run <code>git svn dcommit</code> from <code>master</code>, git will look for changesets between where you are and where <code>git-svn</code> left off. In this case, you only have one: <code>aa70eca</code>. git tries to send that diff to your svn repository.</p> <pre> $ git svn dcommit Committing to [svn repo address] ... M foo.txt Committed r3 M bar.txt r2 = 12b95b96e11f782f31b07a78756660cb82437ca2 (refs/remotes/git-svn) M foo.txt r3 = d4a7b84e0383f3af5fb0db439169c9f1b8af1152 (refs/remotes/git-svn) W: aa70ecae4121854ac3754fb882a483b67d706a4a and refs/remotes/git-svn differ, using rebase: :100644 100644 5771152459bfaa7cc62caa3b6b4d24e52ab8e447 dbfaecb10330d0509e092f1891a4a7e673802413 M bar.txt First, rewinding head to replay your work on top of it... Nothing to do. $ git log --oneline --decorate d4a7b84 (git-svn, master) Added a line to foo. 12b95b9 Added to bar. 7e72290 Initial commit. </pre> <p>You can see that the commit succeeded as svn revision 3. When git-svn then sync'd your local svn history with the svn repository, it fetched all the new commits <em>including the change you just submitted to svn</em>. You'll notice that this change (<code>d4a7b84</code>) has a different SHA hash from the one you used to have in git (<code>aa70eca</code>). This is due to a variety of things: different commit timestamps, potentially different author names, the <code>git-svn-id</code> in the log of the commit fetched from svn, and different ancestry&mdash; the fetched svn r3 has r2 as its parent, but your git commit was descended from r1.</p> <p>In this scenario, there was a diff found after fetching between the current git head (<code>master</code>) and SVN, since the content in r2 changed <code>foo.txt</code>. As a result, <code>git-svn</code> will rebase.</p> <p>If I make a change and no other svn commits occurred in the meantime (or I had been running <code>git svn rebase</code> to keep up to date), then <code>git-svn</code> won't find a diff between the head and SVN, so it can just reset:</p> <pre> $ git svn dcommit Committing to [svn repo address] ... M foo.txt Committed r4 M foo.txt r4 = 533f7337999778628cf39fcd9155d085eb1c2b89 (refs/remotes/git-svn) No changes between current HEAD and refs/remotes/git-svn Resetting to the latest refs/remotes/git-svn </pre>
 

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