{"thread":{"id":"27857","subject":"git svn push, git dcommit leads to commit duplication?","startedAt":"2011-07-19T19:55:23Z","lastAt":"2011-07-21T10:25:42Z","messageCount":2,"participants":["rupert THURNER","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"171696","messageId":"CAJs9aZ8T+LSOGs-kdncfSJeLANtZqudwc0r-epV7BQ1t4huX9Q@mail.gmail.com","threadId":"27857","inReplyTo":null,"subject":"git svn push, git dcommit leads to commit duplication?","fromName":"rupert THURNER","fromEmail":"rupert.thurner@gmail.com","sentAt":"2011-07-19T19:55:23Z","receivedAt":"2011-07-19T19:55:23Z","isPatch":false,"sender":{"key":"rupert.thurner@gmail.com","avatar":null},"body":"we keep a svn clone of\nhttps://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg on\nhttps://github.com/opencsw/pkg-all . usually i synchronize it with\n\"git svn rebase\" and \"git push\" from a local clone created with \"git\nsvn clone https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg\".\n\nlast time i changed something in this local clone and pushed it to\ngithub, and commited it to sourceforge via git svn dcommit. now the\ncommits are there two times, different. my guess was that dcommit\nwould add the svn related stuff to the existing git commits. what is\nthe correct usage to keep svn and git in sync?\n\n$ git log origin/master..master\n...\ncommit 38ed3e4dec877b356fbf3799d1419a89ce6d107f\nAuthor: rthurner <rthurner@d3b55034-1cff-0310-a425-aefe953e1e90>\nDate:   Sun Jul 17 09:25:14 2011 +0000\n\n    libserf, obsolete devel, and not working 0-0 package\n\n    git-svn-id:\nhttps://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg@15081\nd3b55034-1cff-0310-a425-aefe953e1e90\n\ncommit 22340c05f87b19bde70fd04016bee39e24bb6c8b\nAuthor: rthurner <rthurner@d3b55034-1cff-0310-a425-aefe953e1e90>\nDate:   Sun Jul 17 09:24:53 2011 +0000\n\n    libserf, obsolete devel, and not working 0-0 package\n\n    git-svn-id:\nhttps://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg@15080\nd3b55034-1cff-0310-a425-aefe953e1e90\n\n\n$ git log master..origin/master\ncommit 25bf83cd73ad5ffb17a5bfb668ecdbde1b8971bd\nAuthor: THURNER rupert <rupert@opencsw.org>\nDate:   Sun Jul 17 11:23:15 2011 +0200\n\n    libserf, obsolete devel, and not working 0-0 package\n\ncommit cd516e0f4a319ba2554ca29a911130b43b96f6ec\nAuthor: THURNER rupert <rupert@opencsw.org>\nDate:   Sun Jul 17 11:21:36 2011 +0200\n\n    libserf, obsolete devel, and not working 0-0 package\n"},{"id":"171811","messageId":"201107211225.42860.trast@student.ethz.ch","threadId":"27857","inReplyTo":"CAJs9aZ8T+LSOGs-kdncfSJeLANtZqudwc0r-epV7BQ1t4huX9Q@mail.gmail.com","subject":"Re: git svn push, git dcommit leads to commit duplication?","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-07-21T10:25:42Z","receivedAt":"2011-07-21T10:25:42Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"rupert THURNER wrote:\n> we keep a svn clone of\n> https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg on\n> https://github.com/opencsw/pkg-all . usually i synchronize it with\n> \"git svn rebase\" and \"git push\" from a local clone created with \"git\n> svn clone https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg\".\n> \n> last time i changed something in this local clone and pushed it to\n> github, and commited it to sourceforge via git svn dcommit. now the\n> commits are there two times, different. my guess was that dcommit\n> would add the svn related stuff to the existing git commits. what is\n> the correct usage to keep svn and git in sync?\n\nYour guess is mostly correct.  To best understand what is going on,\nkeep in mind that \"you can never modify, you can only rewrite and\nforget\"[1].\n\nSuppose you say 'git svn dcommit' on history that looks like\n\n  1---2---3--(4)--(5)    SVN\n\n  o---o---o    (svn/trunk)\n           \\\n            a---b---c   (master)\n\nwhere 4 and 5 are commits not yet fetched from SVN (if any).\n\n\n1. git-svn will first fetch the new SVN history, let's call them N:\n\n     1---2---3---4---5    SVN\n\n     o---o---o---N---N    (svn/trunk)\n              \\\n               a---b---c   (master)\n\n2. Then it will rebase your own work on top of the new SVN stuff:\n\n     1---2---3---4---5    SVN\n\n     o---o---o---N---N    (svn/trunk)\n              \\\n               a---b---c   (master)\n\n\n3. Then it will rebase your own work on top of the new SVN stuff:\n\n     1---2---3---4---5    SVN\n\n     o---o---o---N---N    (svn/trunk)\n                      \\\n                       a'--b'--c'   (master)\n\n4. Then it will commit all of that to SVN:\n\n     1---2---3---4---5---6---7---8    SVN\n\n     o---o---o---N---N    (svn/trunk)\n                      \\\n                       a'--b'--c'   (master)\n\n5. Then it will annotate your commits o' with the info coming back\n   from SVN (such as author, etc.) and \"replace\" your master with it:\n\n     1---2---3---4---5---6---7---8    SVN\n\n     o---o---o---N---N---A---B---C    (svn/trunk, master)\n\n   From the point of view of 'master', this is also much like a\n   rebase, except that authors and timestamps change too and (unless\n   disabled) git-svn-id: lines appear in your commit messages.\n\n\nDoes that clarify what happens?\n\n[For the sake of completeness, I should point out that this is a\nsimplification.  Steps 3--5 are actually all done in one go *per\ncommit*, and step 3 does not use 'git-rebase' but a variant on the\ntheme that preserves merges of side branches.]\n\n\nAs for\n\n> what is the correct usage to keep svn and git in sync?\n\nthe only way I know of that avoids constantly rebasing branches is to\nnever push anything before it has been dcommitted.\n\n\n[1] Quoting Tv; he said it much better than I can.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}