{"id":3496,"date":"2020-01-29T19:55:56","date_gmt":"2020-01-29T10:55:56","guid":{"rendered":"https:\/\/www.chihayafuru.jp\/tech\/?p=3496"},"modified":"2021-12-17T09:06:58","modified_gmt":"2021-12-17T00:06:58","slug":"git-stash","status":"publish","type":"post","link":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/archives\/3496","title":{"rendered":"[git] stash"},"content":{"rendered":"<h3>1. git stash pop \u3067 conflict \u3057\u305f\u3068\u304d<\/h3>\n<h4>1.0 conflist\u306e\u4f8b<\/h4>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git stash pop\r\nAuto-merging inc\/foo.h\r\nCONFLICT (content): Merge conflict in inc\/foo.h\r\nAuto-merging src\/bar.c\r\nCONFLICT (content): Merge conflict in src\/bar.c\r\nThe stash entry is kept in case you need it again.<\/pre>\n<p><!--more--><\/p>\n<h4>1.1. stash \u3092\u306a\u304b\u3063\u305f\u3053\u3068\u306b\u3059\u308b<\/h4>\n<h5>(1) work\u3082\u542b\u3081\u3066\u3001\u5168\u3066\u3092 pop \u4ee5\u524d\u306b\u623b\u3059\u3002<\/h5>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git reset HEAD --hard<\/pre>\n<h5>(2) stash \u3092 \u524a\u9664\u3059\u308b\u3002<\/h5>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git stash drop  # \u6700\u65b0\u306estash\u3092\u524a\u9664<\/pre>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git stash drop stash@{N}  # N\u756a\u76ee\u306estash\u3092\u524a\u9664<\/pre>\n<h4>1.2. \u7af6\u5408\u3092\u89e3\u6c7a\u3059\u308b<\/h4>\n<h5>(1) \u624b\u4f5c\u696d\u3067\u7af6\u5408\u3092\u89e3\u6c7a\u3059\u308b<\/h5>\n<h5>(2) unstage\u3059\u308b(git\u306e\u5185\u90e8\u72b6\u614b\u3092\u623b\u3059)<\/h5>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git reset HEAD &lt;file&gt;<\/pre>\n<h5>(3) \u9069\u5b9c\u3001add \u3084 commit \u3092\u884c\u3046<\/h5>\n<p>&nbsp;<\/p>\n<h3>2. \u90e8\u5206\u7684\u306a\u9000\u907f (stash)<\/h3>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git stash save -p<\/pre>\n<h4>-p \u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u5b9f\u884c\u4f8b<\/h4>\n<pre class=\"lang:default highlight:0 decode:true \" >diff --git a\/foo.c b\/foo.c\r\nindex f2289bf..a2c60c2 100644\r\n--- a\/foo.c\r\n+++ b\/foo.c\r\n@@ -13,7 +13,7 @@\r\n #include       <stdio.h>\r\n #include       <stdlib.h>\r\n #include       <string.h>\r\n-#include       \"FOO.h\"\r\n+#include       \"foo.h\"\r\n #include       \"fizz.h\"\r\n #include       \"buzz.h\"\r\n(1\/1) Stash this hunk [y,n,q,a,d,e,?]?<\/pre>\n<p>&nbsp;<\/p>\n<h3>3. \u6bd4\u8f03<\/h3>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git diff HEAD..stash      # \u6700\u65b0\u306estash\u3068\u6bd4\u8f03<\/pre>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git diff HEAD..stash@{N}  # N\u756a\u76ee\u306estash\u3068\u6bd4\u8f03<\/pre>\n<p>&nbsp;<\/p>\n<h3>4. \u95a2\u9023\u30ea\u30f3\u30af<\/h3>\n<ul>\n<li><a href=\"\/tech\/index.php\/archives\/2721\">[git] WIP\u3068\u306f<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. git stash pop \u3067 conflict \u3057\u305f\u3068\u304d 1.0 conflist\u306e\u4f8b $ git stash pop Auto-merging inc\/foo.h CONFLICT (content): Mer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2],"class_list":["post-3496","post","type-post","status-publish","format-standard","hentry","category-memo","tag-git"],"_links":{"self":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/3496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/comments?post=3496"}],"version-history":[{"count":14,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/3496\/revisions"}],"predecessor-version":[{"id":4928,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/3496\/revisions\/4928"}],"wp:attachment":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/media?parent=3496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/categories?post=3496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/tags?post=3496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}