{"id":212459,"date":"2021-03-10T10:06:33","date_gmt":"2021-03-10T02:06:33","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=212459"},"modified":"2021-02-26T10:07:16","modified_gmt":"2021-02-26T02:07:16","slug":"git-checkout-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/git-checkout-linux.html","title":{"rendered":"\u6559\u4f60\u5982\u4f55\u4eceGit\u4e0acheckout\u6307\u5b9a\u7684\u6587\u4ef6\u5939\u81f3\u672c\u5730\u7684\u4ee3\u7801"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u4eceGit\u4e0acheckout\u6307\u5b9a\u7684\u6587\u4ef6\u5939\u81f3\u672c\u5730\u7684\u4ee3\u7801,\u672c\u6587\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u7684\u975e\u5e38\u8be6\u7ec6\uff0c\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6216\u5de5\u4f5c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u501f\u9274\u4ef7\u503c\uff0c\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5f53\u9879\u76ee\u8fc7\u5927\u65f6\uff0c\u4ece\u670d\u52a1\u5668\u4e0a\u62c9\u53d6\u9879\u76ee\u662f\u4ef6\u5f88\u5934\u75bc\u7684\u4e8b\u60c5\uff0c\u90a3\u4e48\u5c31\u8bf4\u8bf4\u600e\u4e48\u53ea\u62c9\u533a\u67d0\u4e2a\u6216\u51e0\u4e2a\u6587\u4ef6\u5939\u81f3\u672c\u5730\u3002<\/p>\n

\u4e0a\u4ee3\u7801\uff1a<\/p>\n

\r\ngit clone -n git@172.0.0.10:test\/test_platform.git\r\ncd test_platform\r\ngit config core.sparsecheckout true\r\necho webapp\/css >> .git\/info\/sparse-checkout\r\ngit checkout master<\/pre>\n

\u5982\u679c\u9700\u8981 check out \u591a\u4e2a\u6587\u4ef6\u5939\u7684\u8bdd\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002<\/p>\n

\r\necho webapp\/js >> .git\/info\/sparse-checkout\r\necho webapp\/img >> .git\/info\/sparse-checkout<\/pre>\n

\u6700\u540e\u7ee7\u7eed \u6267\u884c\u547d\u4ee4\uff0ccheckout \u9879\u76ee\u81f3\u672c\u5730<\/p>\n

\r\ngit checkout master<\/pre>\n

\u7b80\u5355\u5b9e\u7528\uff0c\u8d70\u8d77\u6765\u5427\uff01<\/p>\n

PS\uff1a\u4e0b\u9762\u770b\u4e0bGit\u8bed\u6cd5\u4e4bCheckout\u4f7f\u7528<\/p>\n

\u60c5\u51b5\u4e00:\u672a\u4f7f\u7528 git add \u7f13\u5b58\u4ee3\u7801\u65f6:<\/strong><\/span><\/div>\n
\r\n\/\/ \u653e\u5f03\u5355\u4e2a\u6587\u4ef6\u4fee\u6539,\u6ce8\u610f\u4e0d\u8981\u5fd8\u8bb0\u4e2d\u95f4\u7684\"--\",\u4e0d\u5199\u5c31\u6210\u4e86\u68c0\u51fa\u5206\u652f\u4e86!\r\ngit checkout -- filepathname\r\n\/\/ \u653e\u5f03\u6240\u6709\u7684\u6587\u4ef6\u4fee\u6539\r\ngit checkout .<\/pre>\n

\u6b64\u547d\u4ee4\u7528\u6765\u653e\u5f03\u6389\u6240\u6709\u8fd8\u6ca1\u6709\u52a0\u5165\u5230\u7f13\u5b58\u533a\uff08\u5c31\u662f git add \u547d\u4ee4\uff09\u7684\u4fee\u6539\uff1a\u5185\u5bb9\u4fee\u6539\u4e0e\u6574\u4e2a\u6587\u4ef6\u5220\u9664\u3002\u4f46\u662f\u6b64\u547d\u4ee4\u4e0d\u4f1a\u5220\u9664\u6389\u521a\u65b0\u5efa\u7684\u6587\u4ef6\u3002\u56e0\u4e3a\u521a\u65b0\u5efa\u7684\u6587\u4ef6\u8fd8\u6ca1\u5df2\u6709\u52a0\u5165\u5230 git \u7684\u7ba1\u7406\u7cfb\u7edf\u4e2d\u3002\u6240\u4ee5\u5bf9\u4e8egit\u662f\u672a\u77e5\u7684\u3002\u81ea\u5df1\u624b\u52a8\u5220\u9664\u5c31\u597d\u4e86\u3002<\/p>\n

\u60c5\u51b5\u4e8c:\u5df2\u7ecf\u4f7f\u7528\u4e86 git add \u7f13\u5b58\u4e86\u4ee3\u7801:<\/strong><\/span><\/div>\n

\u53ef\u4ee5\u4f7f\u7528 git reset HEAD filepathname \uff08\u6bd4\u5982\uff1a git reset HEAD readme.md\uff09\u6765\u653e\u5f03\u6307\u5b9a\u6587\u4ef6\u7684\u7f13\u5b58\uff0c\u653e\u5f03\u6240\u6709\u7684\u7f13\u5b58\u53ef\u4ee5\u4f7f\u7528 git reset HEAD . \u547d\u4ee4\u3002<\/p>\n

\u6b64\u547d\u4ee4\u7528\u6765\u6e05\u9664 git \u5bf9\u4e8e\u6587\u4ef6\u4fee\u6539\u7684\u7f13\u5b58\u3002\u76f8\u5f53\u4e8e\u64a4\u9500 git add \u547d\u4ee4\u6240\u5728\u7684\u5de5\u4f5c\u3002\u5728\u4f7f\u7528\u672c\u547d\u4ee4\u540e\uff0c\u672c\u5730\u7684\u4fee\u6539\u5e76\u4e0d\u4f1a\u6d88\u5931\uff0c\u800c\u662f\u56de\u5230\u4e86\u5982\uff08\u4e00\uff09\u6240\u793a\u7684\u72b6\u6001\u3002\u7ee7\u7eed\u7528\uff08\u4e00\uff09\u4e2d\u7684\u64cd\u4f5c\uff0c\u5c31\u53ef\u4ee5\u653e\u5f03\u672c\u5730\u7684\u4fee\u6539\u3002<\/p>\n

\u60c5\u51b5\u4e09:\u5df2\u7ecf\u7528 git commit \u63d0\u4ea4\u4e86\u4ee3\u7801:<\/strong><\/span><\/div>\n

\u53ef\u4ee5\u4f7f\u7528 **git reset --hard HEAD^ \u6765\u56de\u9000\u5230\u4e0a\u4e00\u6b21commit\u7684\u72b6\u6001\u3002\u6b64\u547d\u4ee4\u53ef\u4ee5\u7528\u6765\u56de\u9000\u5230\u4efb\u610f\u7248\u672c\uff1agit reset --hard commitid **<\/p>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528 **git log **\u547d\u4ee4\u6765\u67e5\u770bgit\u7684\u63d0\u4ea4\u5386\u53f2\u3002git log \u7684\u8f93\u51fa\u5982\u4e0b,\u4e4b\u4e00\u8fd9\u91cc\u53ef\u4ee5\u770b\u5230\u7b2c\u4e00\u884c\u5c31\u662f commitid\uff1a<\/p>\n

\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8e\u4eceGit\u4e0acheckout\u6307\u5b9a\u7684\u6587\u4ef6\u5939\u81f3\u672c\u5730\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5f53\u9879\u76ee\u8fc7\u5927\u65f6\uff0c\u4ece\u670d\u52a1\u5668\u4e0a\u62c9\u53d6\u9879\u76ee\u662f\u4ef6\u5f88\u5934\u75bc\u7684\u4e8b\u60c5\uff0c\u90a3\u4e48\u5c31\u8bf4\u8bf4\u600e\u4e48\u53ea\u62c9\u533a\u67d0\u4e2a\u6216\u51e0\u4e2a\u6587\u4ef6\u5939\u81f3\u672c\u5730\u3002 \u4e0a\u4ee3\u7801\uff1a gi […]<\/p>\n","protected":false},"author":1482,"featured_media":95067,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-212459","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/212459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=212459"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/212459\/revisions"}],"predecessor-version":[{"id":212462,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/212459\/revisions\/212462"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/95067"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=212459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=212459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=212459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}