{"id":239,"date":"2016-03-21T00:21:47","date_gmt":"2016-03-20T23:21:47","guid":{"rendered":"http:\/\/davikingcode.com\/blog\/?p=239"},"modified":"2016-03-21T00:22:54","modified_gmt":"2016-03-20T23:22:54","slug":"reset-git-repository-to-a-new-commit","status":"publish","type":"post","link":"https:\/\/davikingcode.com\/blog\/reset-git-repository-to-a-new-commit\/","title":{"rendered":"Reset git repository to a new commit"},"content":{"rendered":"<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Git_%28software%29\" target=\"_blank\">Git<\/a> is an awesome version control system, popularized by <a href=\"https:\/\/github.com\/\" target=\"_blank\">Github<\/a>. Working on a big project, you might need to add (huge) binaries, or libraries, or even psds, videos&#8230; to your repository. We&#8217;ll not judge this method, it has its pros &#038; cons. The fact is: if those big files change often, your repository will increase very quickly. And sometimes your own code versioning is not a big deal. It&#8217;s stable, and for newcomer it doesn&#8217;t need all the git history and its 4Go (yeah, I already experienced that). So let see how to reset your git repository to a new commit:<\/p>\n<p>Firsty, save your local <em>.git\/config<\/em> file somewhere on your disk. Then:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">rm -rf .git\r\ngit init<\/pre>\n<p>Import and overwrite your previous <em>.git\/config<\/em> file. Then:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">git add .\r\ngit commit -m &quot;Repository reset&quot;\r\ngit push -f origin master<\/pre>\n<p>Et voil\u00e0!<\/p>\n<p>A cool thing to notice is on Github and <a href=\"https:\/\/bitbucket.org\/\" target=\"_blank\">Bitbucket<\/a>, you won&#8217;t lost data subscriptions, stars &#038; forks.<\/p>\n<p>Maybe you need a backup on a specific URL just in case&#8230;? Just create a new repository, and in your <em>.git\/config<\/em> file change the url and push \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git is an awesome version control system, popularized by Github. Working on a big project, you might need to add (huge) binaries, or libraries, or even psds, videos&#8230; to your repository. We&#8217;ll not judge this method, it has its pros &#038; cons. The fact is: if those big files change often, your repository will increase &hellip; <a href=\"https:\/\/davikingcode.com\/blog\/reset-git-repository-to-a-new-commit\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Reset git repository to a new commit<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_discordance_state":"","_discordance_checked":true},"categories":[15],"tags":[24],"_links":{"self":[{"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/posts\/239"}],"collection":[{"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/comments?post=239"}],"version-history":[{"count":5,"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/posts\/239\/revisions"}],"predecessor-version":[{"id":244,"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/posts\/239\/revisions\/244"}],"wp:attachment":[{"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/media?parent=239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/categories?post=239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davikingcode.com\/blog\/wp-json\/wp\/v2\/tags?post=239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}