{"id":387,"date":"2021-11-15T00:04:11","date_gmt":"2021-11-15T00:04:11","guid":{"rendered":"http:\/\/jplatz.com.br\/syntax\/?p=387"},"modified":"2021-11-15T00:08:52","modified_gmt":"2021-11-15T00:08:52","slug":"git-stash-salvando-tambem-os-arquivos-nao-rastreados","status":"publish","type":"post","link":"https:\/\/jplatz.com.br\/syntax\/2021\/11\/15\/git-stash-salvando-tambem-os-arquivos-nao-rastreados\/","title":{"rendered":"GIT Stash Salvando Tamb\u00e9m os Arquivos N\u00e3o Rastreados"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">git status\n\/\/ Untracked files: new_file.php\n\ngit stash --include-untracked\ngit status\n\/\/ nothing to commit, working tree clean\n\ngit stash pop\ngit status\n\/\/ Untracked files: new_file.php<\/pre>\n\n\n\n<p>Por defini\u00e7\u00e3o o <strong>GIT<\/strong> n\u00e3o inclui os arquivos n\u00e3o rastreados quando estamos fazendo um <strong>stash<\/strong>. Esse comportamento padr\u00e3o tem vantagens no meu ponto de vista por que na maior parte das vezes podemos mant\u00ea-los na working area sem dificuldades.<\/p>\n\n\n\n<p>Mas e quando surgir aquela situa\u00e7\u00e3o onde voc\u00ea tem uma s\u00e9rie de arquivos n\u00e3o rastreados, e quer salvar sua altera\u00e7\u00e3o em andamento tudo numa stash s\u00f3 incluindo todo o pacote, arquivos modificados e arquivos novos n\u00e3o rastreados?<\/p>\n\n\n\n<p>Para estas situa\u00e7\u00f5es o <strong>GIT<\/strong> fornece a op\u00e7\u00e3o <strong><em>&#8211;include-untracked<\/em><\/strong> no comando <strong>git stash<\/strong>. Opcionalmente voc\u00ea pode utilizar o <strong>shorthand -u<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git stash -u<\/pre>\n\n\n\n<p>E sempre tem possibilidade de se adicionar manualmente os arquivos n\u00e3o rastreados para staging area e ent\u00e3o executar um <strong>git stash<\/strong> simples.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git add new_file.php\ngit stash<\/pre>\n\n\n\n<p>O inconveniente desta \u00faltima op\u00e7\u00e3o \u00e9 que, ao restaurar o arquivo ele vai aparecer na <strong>staging area<\/strong> enquanto que com a op\u00e7\u00e3o de arquivos n\u00e3o rastreados a restaura\u00e7\u00e3o ser\u00e1 feita diretamente na <strong>working area<\/strong> como arquivo n\u00e3o rastreado.<\/p>\n\n\n\n<p>Recomendo ainda utilizar o recurso de nomear o stash, o que provavelmente far\u00e1 muito sentido quando voc\u00ea querer salvar arquivos n\u00e3o rastreados.<\/p>\n\n\n\n<p>J\u00e1 escrevi um artigo aqui no blog que ensina como nomear o seu stash, \u00e9 s\u00f3 pesquisar &#8220;como nomear seu stash&#8221;.<\/p>\n\n\n\n<p>Voil\u00e0!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>git status \/\/ Untracked files: new_file.php git stash &#8211;include-untracked git status \/\/ nothing to commit, working tree clean git stash pop git status \/\/ Untracked files: new_file.php Por defini\u00e7\u00e3o o GIT n\u00e3o inclui os arquivos n\u00e3o rastreados quando estamos fazendo um stash. Esse comportamento padr\u00e3o tem vantagens no meu ponto de vista por que na [&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,129,172],"class_list":["post-387","post","type-post","status-publish","format-standard","hentry","category-dev-ops","category-git","tag-git","tag-git-stash","tag-untracked-files"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/posts\/387","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=387"}],"version-history":[{"count":3,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/posts\/387\/revisions"}],"predecessor-version":[{"id":391,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/posts\/387\/revisions\/391"}],"wp:attachment":[{"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/media?parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/categories?post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jplatz.com.br\/syntax\/wp-json\/wp\/v2\/tags?post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}