{"id":16,"date":"2020-08-20T02:06:53","date_gmt":"2020-08-20T02:06:53","guid":{"rendered":"https:\/\/blog.napath.com\/?p=16"},"modified":"2020-08-20T02:06:53","modified_gmt":"2020-08-20T02:06:53","slug":"how-to-reset-and-clean-git","status":"publish","type":"post","link":"https:\/\/blog.napath.com\/index.php\/2020\/08\/20\/how-to-reset-and-clean-git\/","title":{"rendered":"How to reset and clean git?"},"content":{"rendered":"\n<p>Recently, I need to run a command to rest and clean local git frequently, but I always forgot the command. Therefore in this post, I write it as a note on how to reset and clean our local git directory. The short answer should be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$git reset --hard &amp;&amp; git clean -d -x -f<\/code><\/pre>\n\n\n\n<p>The command should completely reset and clean your git folder. Any modified or untracked files will be removed. The command consists of two important commands line, &#8220;git reset&#8221; and &#8220;git clean&#8221;.<\/p>\n\n\n\n<p>\u201cgit reset\u201d reset modified files <\/p>\n\n\n\n<p>&#8220;git clean&#8221; remove untracked files. <\/p>\n\n\n\n<p>Parameters:<br>&#8220;&#8211;hard&#8221; means reseting the index and working tree.<br>&#8220;-d&#8221; means including directories.<br>&#8220;-x&#8221; means including files ignored by git.<br>&#8220;-f&#8221; means force to delete.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I need to run a command to rest and clean local git frequently, but I always forgot the command. Therefore in this post, I write it as a note on how to reset and clean our local git directory. The short answer should be: The command should completely reset and clean your git folder. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.napath.com\/index.php\/2020\/08\/20\/how-to-reset-and-clean-git\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to reset and clean git?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":87,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,12],"tags":[18,5,4],"_links":{"self":[{"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/posts\/16"}],"collection":[{"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":8,"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/posts\/16\/revisions\/89"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/media\/87"}],"wp:attachment":[{"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.napath.com\/index.php\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}