{"id":338,"date":"2022-05-08T16:55:40","date_gmt":"2022-05-08T08:55:40","guid":{"rendered":"http:\/\/madapapa.com\/wordpress\/?p=338"},"modified":"2022-05-08T18:06:35","modified_gmt":"2022-05-08T10:06:35","slug":"git-xiao-ji-qiao","status":"publish","type":"post","link":"http:\/\/madapapa.com\/wordpress\/?p=338","title":{"rendered":"Git \u5c0f\u6280\u5de7"},"content":{"rendered":"<p>\u83b7\u53d6\u7b2c\u4e8c\u7ae0\u7684sample\u4ee3\u7801<\/p>\n<pre><code class=\"language-plain_text\">git checkout v0.2\n<\/code><\/pre>\n<p>\u4ece0.1\u5207\u6362\u52300.2\u65f6\uff0c\u51fa\u73b0\u5982\u4e0b\u544a\u8b66<\/p>\n<pre><code class=\"language-plain_text\">git checkout v0.2\nerror: Your local changes to the following files would be overwritten by checkout:\n        app\/routes.py\nPlease commit your changes or stash them before you switch branches.\nAborting\n<\/code><\/pre>\n<p>\u6211\u9009\u62e9\u653e\u5f03\u672c\u5730\u4fee\u6539\uff0c\u5207\u6362\u5230\u5176\u4ed6\u7ae0\u8282\u7684\u4ee3\u7801\uff0c\u8fd8\u6709\u51e0\u79cd\u5907\u9009\u65b9\u6848\uff0c\u53ef\u4ee5\u770b\u53c2\u8003\u3002<\/p>\n<pre><code class=\"language-plain_text\">git reset --hard\nHEAD is now at 23b3fc8 Chapter 1: Hello, World! (v0.1)\n(venv) XXXXXX microblog % git checkout v0.2\nPrevious HEAD position was 23b3fc8 Chapter 1: Hello, World! (v0.1)\nHEAD is now at 5d45592 Chapter 2: Templates (v0.2)\n<\/code><\/pre>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/15745045\/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me\">\u53c2\u8003<\/a>\uff1a<\/p>\n<pre><code class=\"language-plain_text\">you have three options:\n\nCommit the change using\ngit commit -m &quot;My message&quot;\nStash it.\nStashing acts as a stack, where you can push changes, and you pop them in reverse order.\n\nTo stash, type\n\ngit stash\nDo the merge, and then pull the stash:\n\ngit stash pop\nDiscard the local changes\nusing git reset --hard\nor git checkout -t -f remote\/branch\n\nOr: Discard local changes for a specific file\nusing git checkout filename\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u83b7\u53d6\u7b2c\u4e8c\u7ae0\u7684sample\u4ee3\u7801 git checkout v0.2 \u4ece0.1\u5207\u6362\u52300.2\u65f6\uff0c\u51fa\u73b0\u5982\u4e0b\u544a\u8b66 git checkout v0.2 error: Your local changes to the following files would be overwritten by checkout: app\/routes.py Please commit your changes or stash them before you switch branches. Aborting \u6211\u9009\u62e9\u653e\u5f03\u672c\u5730\u4fee\u6539\uff0c\u5207\u6362\u5230\u5176\u4ed6\u7ae0\u8282\u7684\u4ee3\u7801\uff0c\u8fd8\u6709\u51e0\u79cd\u5907\u9009\u65b9\u6848\uff0c\u53ef\u4ee5\u770b\u53c2\u8003\u3002 git reset &#8211;hard HEAD is now at 23b3fc8 Chapter 1: Hello, World! (v0.1) (venv) XXXXXX microblog % git checkout v0.2 &hellip; <a href=\"http:\/\/madapapa.com\/wordpress\/?p=338\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Git \u5c0f\u6280\u5de7<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-338","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=338"}],"version-history":[{"count":3,"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/338\/revisions"}],"predecessor-version":[{"id":341,"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/338\/revisions\/341"}],"wp:attachment":[{"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/madapapa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}