{"id":5783,"date":"2019-12-09T13:25:15","date_gmt":"2019-12-09T18:25:15","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5783"},"modified":"2019-12-09T13:34:06","modified_gmt":"2019-12-09T18:34:06","slug":"git-using-soft-reset-to-clean-up-un-pushed-commits","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5783","title":{"rendered":"Git: Using Soft Reset To Clean Up Un-pushed Commits"},"content":{"rendered":"<p>I missed a file when I was cleaning up debugging lines. I made the change and included it in a second commit, but I&#8217;d rather <em>not<\/em> have two commits for the same purpose. I hadn&#8217;t pushed my changes yet, so these commits only exist on my workstation &#8230; which means I can reset and bundle the changes into a single commit.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"639\" height=\"113\" class=\"wp-image-5784\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image.png 639w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-300x53.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-500x88.png 500w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><\/p>\n<p>Find commit number that is one <em>before<\/em> the duplicate debug logging cleanup &#8212; this is the point to which you want to reset. In my case, it is the commit start with b443348c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"983\" height=\"115\" class=\"wp-image-5785\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-1.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-1.png 983w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-1-300x35.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-1-768x90.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-1-500x58.png 500w\" sizes=\"auto, (max-width: 983px) 100vw, 983px\" \/><\/p>\n<p>Reset there with &#8220;&#8211;soft&#8221; &#8212; this doesn&#8217;t change anything on the file system (i.e. I don&#8217;t have to clean up those debug lines <em>again<\/em>) but puts the changes back into the staging area.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"60\" class=\"wp-image-5786\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-2.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-2.png 699w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-2-300x26.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-2-500x43.png 500w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/p>\n<p>Now those files are staged again, so I can make a single commit for removing debug logging from my code.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"472\" height=\"257\" class=\"wp-image-5787\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-3.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-3.png 472w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-3-300x163.png 300w\" sizes=\"auto, (max-width: 472px) 100vw, 472px\" \/><\/p>\n<p>Voila! I can push these changes and not clutter our history with my error.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"499\" height=\"114\" class=\"wp-image-5788\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-4.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-4.png 499w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/12\/word-image-4-300x69.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I missed a file when I was cleaning up debugging lines. I made the change and included it in a second commit, but I&#8217;d rather not have two commits for the same purpose. I hadn&#8217;t pushed my changes yet, so these commits only exist on my workstation &#8230; which means I can reset and bundle &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[233],"class_list":["post-5783","post","type-post","status-publish","format-standard","hentry","category-coding","tag-git"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5783"}],"version-history":[{"count":3,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5783\/revisions"}],"predecessor-version":[{"id":5791,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5783\/revisions\/5791"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}