{"id":481,"date":"2020-04-09T14:00:30","date_gmt":"2020-04-09T21:00:30","guid":{"rendered":"http:\/\/www.hongyu.org\/wordpress\/?p=481"},"modified":"2020-04-09T15:55:25","modified_gmt":"2020-04-09T22:55:25","slug":"quick-dirty-way-to-clean-git-history","status":"publish","type":"post","link":"https:\/\/www.hongyu.org\/wordpress\/?p=481","title":{"rendered":"Quick dirty way to clean git history"},"content":{"rendered":"\n<div class=\"p-rich_text_section\">Sometimes my git history got messed up due to some strange issues. I use the following quick\/dirty way to create a clean new branch.<\/div>\n<div>\u00c2\u00a0<\/div>\n<div class=\"p-rich_text_section\">Step 1: use the &#8220;git clone&#8221; command to clone the master branch to a separate new folder<\/div>\n<div>\u00c2\u00a0<\/div>\n<div class=\"p-rich_text_section\">Step 2: rsync the changed content of your old branch to the new folder excluding the .git subfolder<\/div>\n<pre class=\"c-mrkdwn__pre\" data-stringify-type=\"pre\">rsync -avz --exclude .git old-folder\/ new-folder<\/pre>\n<div class=\"p-rich_text_section\">Step 3: create a new branch out of the new folder and then push<\/div>\n<pre class=\"c-mrkdwn__pre\" data-stringify-type=\"pre\">$ cd new-folder<br \/>$ git checkout -b my-new-branch<\/pre>\n<p>Lastly, we can avoid lots of hassles if using &#8220;git pull &#8211;rebase&#8221; instead of the simple &#8220;git pull&#8221; command.<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/481"}],"collection":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=481"}],"version-history":[{"count":2,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/481\/revisions"}],"predecessor-version":[{"id":483,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/481\/revisions\/483"}],"wp:attachment":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}