{"id":1821,"date":"2023-07-14T10:56:40","date_gmt":"2023-07-14T02:56:40","guid":{"rendered":"https:\/\/qishiya.com\/?p=1821"},"modified":"2023-07-14T10:56:41","modified_gmt":"2023-07-14T02:56:41","slug":"git-switch-%e5%92%8c-checkout-%e6%9c%89%e4%bb%80%e4%b9%88%e5%8c%ba%e5%88%ab%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/qishiya.com\/?p=1821","title":{"rendered":"git switch \u548c checkout \u6709\u4ec0\u4e48\u533a\u522b\uff1f"},"content":{"rendered":"\n<p><code>git checkout<\/code> \u548c <code>git switch<\/code> \u90fd\u53ef\u4ee5\u7528\u4e8e\u5728\u4e0d\u540c\u5206\u652f\u4e4b\u95f4\u5207\u6362\uff0c\u4f46\u5b83\u4eec\u5728\u8bbe\u8ba1\u4e0a\u6709\u4e00\u4e9b\u533a\u522b\u3002\u4ece Git 2.23 \u7248\u672c\u5f00\u59cb\uff0c<code>git switch<\/code> \u88ab\u5f15\u5165\u4f5c\u4e3a\u4e00\u4e2a\u66f4\u7b80\u5355\u4e14\u66f4\u660e\u786e\u7684\u65b9\u5f0f\u6765\u5207\u6362\u5206\u652f\uff0c\u800c <code>git checkout<\/code> \u8fd9\u4e2a\u547d\u4ee4\u4ecd\u7136\u53ef\u7528\uff0c\u5e76\u4e14\u529f\u80fd\u66f4\u52a0\u4e30\u5bcc\u3002<\/p>\n\n\n\n<p><strong>\u4e3b\u8981\u533a\u522b\uff1a<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>\uff1a<code>git switch<\/code> \u4e3b\u8981\u805a\u7126\u4e8e\u5728\u5206\u652f\u4e4b\u95f4\u8fdb\u884c\u5207\u6362\uff0c\u800c <code>git checkout<\/code> \u53ef\u4ee5\u7528\u4e8e\u5207\u6362\u5206\u652f\u3001\u68c0\u51fa\u7279\u5b9a\u63d0\u4ea4\u3001\u8fd8\u539f\u6587\u4ef6\u7b49\u591a\u79cd\u64cd\u4f5c\u3002<\/li>\n\n\n\n<li><strong>\u6613\u7528\u6027<\/strong>\uff1a<code>git switch<\/code> \u7684\u8bed\u6cd5\u88ab\u8ba4\u4e3a\u662f\u66f4\u7b80\u6d01\u3001\u76f4\u89c2\u7684\uff0c\u5c24\u5176\u5bf9\u4e8e\u65b0\u7528\u6237\u6765\u8bf4\u3002<code>git checkout<\/code> \u7531\u4e8e\u6db5\u76d6\u4e86\u591a\u79cd\u64cd\u4f5c\uff0c\u6240\u4ee5\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u4f1a\u663e\u5f97\u590d\u6742\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong>\u5728\u5206\u652f\u4e4b\u95f4\u5207\u6362\u65f6\u7684\u6bd4\u8f83\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>git switch<\/code> \u5207\u6362\u5230\u5df2\u5b58\u5728\u7684\u5206\u652f\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  git switch &lt;branch-name&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>git checkout<\/code> \u5207\u6362\u5230\u5df2\u5b58\u5728\u7684\u5206\u652f\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  git checkout &lt;branch-name&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>git switch<\/code> \u521b\u5efa\u5e76\u5207\u6362\u5230\u65b0\u5206\u652f\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  git switch -c &lt;new-branch-name&gt; &lt;start-point&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>git checkout<\/code> \u521b\u5efa\u5e76\u5207\u6362\u5230\u65b0\u5206\u652f\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  git checkout -b &lt;new-branch-name&gt; &lt;start-point&gt;<\/code><\/pre>\n\n\n\n<p>\u867d\u7136 <code>git switch<\/code> \u662f\u4e00\u4e2a\u76f8\u5bf9\u8f83\u65b0\u4e14\u4e13\u6ce8\u4e8e\u5206\u652f\u5207\u6362\u7684\u547d\u4ee4\uff0c\u5f88\u591a Git \u7528\u6237\uff08\u7279\u522b\u662f\u65e7\u7248\u672c Git \u7528\u6237\uff09\u53ef\u80fd\u8fd8\u5728\u7ee7\u7eed\u4f7f\u7528 <code>git checkout<\/code>\u3002\u5b9e\u9645\u4e0a\uff0c\u9009\u62e9\u54ea\u4e00\u4e2a\u547d\u4ee4\u53d6\u51b3\u4e8e\u4f60\u4e2a\u4eba\u7684\u504f\u597d\u548c\u4e60\u60ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>git checkout \u548c git switch \u90fd\u53ef\u4ee5\u7528\u4e8e\u5728\u4e0d\u540c\u5206\u652f\u4e4b\u95f4\u5207\u6362\uff0c\u4f46\u5b83\u4eec\u5728\u8bbe\u8ba1\u4e0a\u6709\u4e00\u4e9b\u533a\u522b\u3002\u4ece Git 2.23 \u7248\u672c\u5f00\u59cb\uff0cgit switch \u88ab\u5f15\u5165\u4f5c\u4e3a\u4e00\u4e2a\u66f4\u7b80\u5355\u4e14\u66f4\u660e\u786e\u7684\u65b9\u5f0f\u6765\u5207\u6362\u5206\u652f\uff0c\u800c git checkout \u8fd9 &#8230; <a title=\"git switch \u548c checkout \u6709\u4ec0\u4e48\u533a\u522b\uff1f\" class=\"read-more\" href=\"https:\/\/qishiya.com\/?p=1821\" aria-label=\"\u66f4\u591a git switch \u548c checkout \u6709\u4ec0\u4e48\u533a\u522b\uff1f\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[589],"tags":[588,590],"class_list":["post-1821","post","type-post","status-publish","format-standard","hentry","category-chatgpt","tag-chatgpt","tag-git"],"_links":{"self":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/1821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1821"}],"version-history":[{"count":1,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/1821\/revisions"}],"predecessor-version":[{"id":1822,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/1821\/revisions\/1822"}],"wp:attachment":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}