{"id":482,"date":"2023-06-01T15:59:13","date_gmt":"2023-06-01T15:59:13","guid":{"rendered":"https:\/\/jplatz.com.br\/syntax\/?p=482"},"modified":"2023-06-03T16:43:29","modified_gmt":"2023-06-03T16:43:29","slug":"git-reset-eliminando-um-commit-da-sua-branch","status":"publish","type":"post","link":"https:\/\/jplatz.com.br\/syntax\/2023\/06\/01\/git-reset-eliminando-um-commit-da-sua-branch\/","title":{"rendered":"GIT Reset Eliminando um Commit da sua Branch"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>-- before proceeding be sure working area is clean\ngit status \n\n-- eliminate commit and throw away all changes\ngit reset --hard HEAD~1\n\n-- or if you want to reuse your changes\n-- eliminate commit but keep changes at working area\ngit reset --soft HEAD~1<\/code><\/pre>\n\n\n\n<p>Em algumas situa\u00e7\u00f5es acabamos por introduzir um <strong>commit<\/strong> indesejado numa <strong>branch<\/strong>. Ent\u00e3o o que fazer?<\/p>\n\n\n\n<p>F\u00e1cil, o <strong>RESET<\/strong> est\u00e1 a\u00ed pra isso mesmo.<\/p>\n\n\n\n<p>Usando a op\u00e7\u00e3o <strong>&#8211;hard<\/strong> estamos indicando que as altera\u00e7\u00f5es desfeitas sejam jogadas fora, ou seja, voc\u00ea usa esta op\u00e7\u00e3o quando desistiu mesmo e quer recome\u00e7ar o trabalho do zero.<\/p>\n\n\n\n<p>J\u00e1 a op\u00e7\u00e3o <strong>&#8211;soft<\/strong> estamos indicando que as altera\u00e7\u00f5es desfeitas permane\u00e7am nos arquivos da <strong>working<\/strong> <strong>area<\/strong> para que voc\u00ea possa ainda utiliz\u00e1-los antes de um novo <strong>commit<\/strong>.<\/p>\n\n\n\n<p>Vale lembrar que estamos sacando fora <strong>commits<\/strong> do topo da pilha. Na verdade podemos sacar v\u00e1rios <strong>commits<\/strong> de uma s\u00f3 vez mas sempre ser\u00e1 a partir do topo e em sequ\u00eancia.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- eliminate the top 5 commits in the stack at once\ngit reset --hard HEAD~5<\/code><\/pre>\n\n\n\n<p>Para sacar mais de um <strong>commit<\/strong> por vez basta ajustarmos o <strong>HEAD~{n} <\/strong>onde <strong>n<\/strong> \u00e9 a quantidade de commits a serem removidos.<\/p>\n\n\n\n<p><strong><em>\u00c9 isso, mais f\u00e1cil que cortar manteiga quente!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Em algumas situa\u00e7\u00f5es acabamos por introduzir um commit indesejado numa branch. Ent\u00e3o o que fazer? F\u00e1cil, o RESET est\u00e1 a\u00ed pra isso mesmo. Usando a op\u00e7\u00e3o &#8211;hard estamos indicando que as altera\u00e7\u00f5es desfeitas sejam jogadas fora, ou seja, voc\u00ea usa esta op\u00e7\u00e3o quando desistiu mesmo e quer recome\u00e7ar o trabalho do zero. J\u00e1 a op\u00e7\u00e3o [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,35],"tags":[55,235],"class_list":["post-482","post","type-post","status-publish","format-standard","hentry","category-dev-ops","category-git","tag-git","tag-git-reset"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/posts\/482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/comments?post=482"}],"version-history":[{"count":5,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/posts\/482\/revisions"}],"predecessor-version":[{"id":490,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/posts\/482\/revisions\/490"}],"wp:attachment":[{"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/media?parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/categories?post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/tags?post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}