{"id":3959,"date":"2021-02-24T13:58:26","date_gmt":"2021-02-24T04:58:26","guid":{"rendered":"https:\/\/www.chihayafuru.jp\/tech\/?p=3959"},"modified":"2023-10-31T18:27:46","modified_gmt":"2023-10-31T09:27:46","slug":"git-rm-%e3%81%ae%e5%8f%96%e3%82%8a%e6%b6%88%e3%81%97","status":"publish","type":"post","link":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/archives\/3959","title":{"rendered":"git rm \u306e\u53d6\u308a\u6d88\u3057"},"content":{"rendered":"<p>git rm (\u30d5\u30a1\u30a4\u30eb\u524a\u9664\u30b3\u30de\u30f3\u30c9) \u306e\u53d6\u308a\u6d88\u3057\u65b9\u6cd5<\/p>\n<h3>\u30b3\u30df\u30c3\u30c8\u524d\u306e\u30d5\u30a1\u30a4\u30eb\u524a\u9664\u64cd\u4f5c\u306e\u53d6\u308a\u6d88\u3057<\/h3>\n<h4>\u6982\u8981<\/h4>\n<ol>\n<li><a href=\"#reset\">\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u306e\u53d6\u308a\u8fd4\u3057<\/a><\/li>\n<li><a href=\"#restore\">\u30ef\u30fc\u30af\u30c4\u30ea\u30fc\u306e\u5fa9\u5143<\/a><\/li>\n<\/ol>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<h4>\u8a73\u7d30<\/h4>\n<h5 id=\"reset\">1. \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u306e\u53d6\u308a\u6d88\u3057<\/h5>\n<p>\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0(git add\u30b3\u30de\u30f3\u30c9\u306b\u76f8\u5f53)\u3092\u53d6\u308a\u6d88\u3059\u3002<\/p>\n<h6>1.1. \u53d6\u308a\u6d88\u3057\u65b9\u6cd51<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >git reset HEAD &lt;pathspec&gt;<\/pre>\n<h6>\u53d6\u308a\u6d88\u3057\u65b9\u6cd51\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u4f8b<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git reset HEAD foo.c\r\nUnstaged changes after reset:\r\nD       foo.c<\/pre>\n<h6>1.2. \u53d6\u308a\u6d88\u3057\u65b9\u6cd52<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >git restore --staged &lt;pathspec&gt;<\/pre>\n<h6>\u53d6\u308a\u6d88\u3057\u65b9\u6cd52\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u4f8b<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git restore --staged foo.c<\/pre>\n<p>&nbsp;<\/p>\n<h5 id=\"restore\">2. \u30ef\u30fc\u30af\u30c4\u30ea\u30fc\u306e\u5fa9\u5143<\/h5>\n<p>\u30ef\u30fc\u30af\u30c4\u30ea\u30fc\u3092\u5fa9\u5143\u3059\u308b\u3002\u7de8\u96c6\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u7834\u68c4\u3057\u3066\u5143\u306b\u623b\u3059\u3068\u304d\u3068\u540c\u3058\u624b\u9806\u3002\u305f\u307e\u305f\u307e\u7de8\u96c6\u3067\u306f\u306a\u304f\u524a\u9664\u3067\u3042\u308b\u305f\u3081\u8003\u3048\u8fbc\u3093\u3067\u3057\u307e\u3046\u304c\u3001\u5b9f\u884c\u3059\u308b\u624b\u9806\uff08\u30b3\u30de\u30f3\u30c9\uff09\u306f\u540c\u3058\u3067\u3059\u3002<\/p>\n<h6>2.1. \u5fa9\u5143\u65b9\u6cd51<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >git checkout &lt;pathspec&gt;<\/pre>\n<h6>\u5fa9\u5143\u65b9\u6cd51\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u4f8b<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git checkout foo.c\r\nUpdated 1 path from the index<\/pre>\n<h6>2.2. \u5fa9\u5143\u65b9\u6cd52<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >git restore &lt;pathspec&gt;<\/pre>\n<h6>\u5fa9\u5143\u65b9\u6cd52\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u4f8b<\/h6>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git restore foo.c<\/pre>\n<p>&nbsp;<\/p>\n<hr>\n<p>&nbsp;<\/p>\n<h3>\u30b3\u30df\u30c3\u30c8\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u524a\u9664\u64cd\u4f5c\u306e\u53d6\u308a\u6d88\u3057<\/h3>\n<pre class=\"lang:default highlight:0 decode:true \" >$ git reset --soft HEAD^<\/pre>\n<p>\u3053\u306e\u3042\u3068\u3001\u300c\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u306e\u53d6\u308a\u6d88\u3057\u300d\u3001\u300c\u30ef\u30fc\u30af\u30c4\u30ea\u30fc\u306e\u5fa9\u5143\u300d\u3068\u4f5c\u696d\u3092\u9032\u3081\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u5185\u90e8\u30ea\u30f3\u30af<\/h3>\n<ul>\n<li><a href=\"\/tech\/index.php\/archives\/5758\">git reset<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>git rm (\u30d5\u30a1\u30a4\u30eb\u524a\u9664\u30b3\u30de\u30f3\u30c9) \u306e\u53d6\u308a\u6d88\u3057\u65b9\u6cd5 \u30b3\u30df\u30c3\u30c8\u524d\u306e\u30d5\u30a1\u30a4\u30eb\u524a\u9664\u64cd\u4f5c\u306e\u53d6\u308a\u6d88\u3057 \u6982\u8981 \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u306e\u53d6\u308a\u8fd4\u3057 \u30ef\u30fc\u30af\u30c4\u30ea\u30fc\u306e\u5fa9\u5143<\/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-3959","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\/3959","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=3959"}],"version-history":[{"count":16,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/3959\/revisions"}],"predecessor-version":[{"id":6467,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/posts\/3959\/revisions\/6467"}],"wp:attachment":[{"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/media?parent=3959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/categories?post=3959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chihayafuru.jp\/tech\/index.php\/wp-json\/wp\/v2\/tags?post=3959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}