{"id":308,"date":"2008-10-22T09:51:30","date_gmt":"2008-10-22T17:51:30","guid":{"rendered":"http:\/\/www.codebelay.com\/blog\/?p=308"},"modified":"2010-07-29T08:32:52","modified_gmt":"2010-07-29T16:32:52","slug":"getting-around-the-politics-of-subversion-with-git","status":"publish","type":"post","link":"https:\/\/www.codebelay.com\/blog\/2008\/10\/22\/getting-around-the-politics-of-subversion-with-git\/","title":{"rendered":"Getting Around the Politics of Subversion with git"},"content":{"rendered":"<p>This is the nightmare scenario. You are working with a coder who overwrites your changes in subversion. You&#8217;ve told this coder once, twice, three times, &#8220;Hey, please don&#8217;t do that. Hey, let&#8217;s talk about your changes before you commit them.&#8221;<\/p>\n<p>But this coder for some reason thinks that he or she is the gift of the gods when it comes to coding, and continues to overwrite your changes.<\/p>\n<p>This is where git comes in. If I had learned about this feature of git and the idea of accepting or rejecting changes in git sooner, I would have avoided the whole nightmare of re-comitting code and lengthy merge debates.<\/p>\n<p>Most projects you work won&#8217;t involve the worst case above. Most of the time, there will be a great developing rule that says never commit bugs into subversion. But whenever you have to re-factor code and commit each line, branching and then later merging can be an issue in subversion, and it&#8217;s slow too.<\/p>\n<p>On a project that I&#8217;m working on now the client wants only good code in svn which is great, and so I&#8217;m using git with svn. I got this idea thanks to <a href=\"http:\/\/felocity.org\/\">Jakob Heuser<\/a>. Thanks, Jakob!!!!<\/p>\n<p>This is where git comes in. Here&#8217;s a quick cheat sheet and it assumes you are using <a href=\"https:\/\/github.com\/\">GitHub<\/a>:<\/p>\n<div style=\"background: #000; color: #fff; padding: 5px 5px 5px 5px;\">\nmkdir newlispoauth<br \/>\ncd newlispoauth\/<br \/>\ngit init<br \/>\ntouch README<br \/>\ngit add README<br \/>\ngit commit -m &#8216;first commit&#8217;<br \/>\ngit remote add origin git@github.com:barce\/newlispoauth.git<br \/>\ngit push origin master\n<\/div>\n<p>Now we have to pull in changes from subversion:<\/p>\n<div style=\"background: #000; color: #fff; padding: 5px 5px 5px 5px;\">\nmate .git\/config\n<\/div>\n<p>In the config file add something that looks like this:<\/p>\n<div style=\"background: #000; color: #fff; padding: 5px 5px 5px 5px;\">\n[svn-remote &#8220;newlispoauth\/trunk&#8221;]<br \/>\n&nbsp;&nbsp;url = http:\/\/codebelay.com\/newlispoauth\/trunk<br \/>\n&nbsp;&nbsp;fetch = :refs\/remotes\/newlispoauth\/trunk\n<\/div>\n<p>Now we&#8217;re gonna fetch the subversion repo:<\/p>\n<div style=\"background: #000; color: #fff; padding: 5px 5px 5px 5px;\">\ngit-svn fetch newlispoauth\/trunk<br \/>\ngit checkout -b local-svn\/trunk newlispoauth\/trunk<br \/>\ngit svn rebase<br \/>\ngit checkout master<br \/>\ngit merge local-svn\/trunk<br \/>\ngit mergetool # if there are conflicts with the README file above<br \/>\ngit add README # if you had to make changes with the mergetool<br \/>\ngit commit<br \/>\ngit push origin master\n<\/div>\n<p>Now you are working with &#8220;master&#8221; and &#8220;local-svn\/trunk&#8221;.<\/p>\n<p>&#8220;master&#8221; is for your changes to share with your team on git-hub<br \/>\n&#8220;local-svn\/trunk&#8221; is for you and where you push changes to subversion.<\/p>\n<p>You basically pull in changes from newlispoauth\/trunk and do your work in local-svn\/trunk.<\/p>\n<p>Let&#8217;s put the changes in master into &#8220;newlispoauth\/trunk&#8221; and commit those changes to subversion:<\/p>\n<div style=\"background: #000; color: #fff; padding: 5px 5px 5px 5px;\">\ngit checkout local-svn\/trunk # you did commit your changes in origin right?<br \/>\ngit merge master<br \/>\ngit-svn dcommit\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is the nightmare scenario. You are working with a coder who overwrites your changes in subversion. You&#8217;ve told this coder once, twice, three times, &#8220;Hey, please don&#8217;t do that. Hey, let&#8217;s talk about your changes before you commit them.&#8221; But this coder for some reason thinks that he or she is the gift of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[206,4,33],"tags":[399,150,165],"class_list":["post-308","post","type-post","status-publish","format-standard","hentry","category-git","category-how-to","category-webapps","tag-git","tag-svn","tag-version-control"],"_links":{"self":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":0,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}