{"id":521,"date":"2022-02-20T11:30:52","date_gmt":"2022-02-20T03:30:52","guid":{"rendered":"http:\/\/www.lijiapeng.cn\/?p=521"},"modified":"2026-03-03T16:31:46","modified_gmt":"2026-03-03T08:31:46","slug":"git","status":"publish","type":"post","link":"https:\/\/bestcoder.cn\/git","title":{"rendered":"git\u539f\u7406\u548c\u547d\u4ee4"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_72 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\"><\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%8E%9F%E7%90%86\" title=\"\u539f\u7406\">\u539f\u7406<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%9F%BA%E7%A1%80%E5%91%BD%E4%BB%A4\" title=\"\u57fa\u7840\u547d\u4ee4\">\u57fa\u7840\u547d\u4ee4<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%8B%89%E5%BA%93%E5%92%8C%E6%9B%B4%E6%96%B0\" title=\"\u62c9\u5e93\u548c\u66f4\u65b0\">\u62c9\u5e93\u548c\u66f4\u65b0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%8B%89%E5%8F%96%E5%88%86%E6%94%AF\" title=\"\u62c9\u53d6\u5206\u652f\">\u62c9\u53d6\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%88%9B%E5%BB%BA%E5%88%86%E6%94%AF\" title=\"\u521b\u5efa\u5206\u652f\">\u521b\u5efa\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%9F%A5%E7%9C%8B%E5%88%86%E6%94%AF\" title=\"\u67e5\u770b\u5206\u652f\">\u67e5\u770b\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%88%A0%E6%96%87%E4%BB%B6\" title=\"\u5220\u6587\u4ef6\">\u5220\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/bestcoder.cn\/git\/#%E9%87%8D%E7%BD%AE%E4%BB%A3%E7%A0%81\" title=\"\u91cd\u7f6e\u4ee3\u7801\">\u91cd\u7f6e\u4ee3\u7801<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%88%A0%E5%88%86%E6%94%AF\" title=\"\u5220\u5206\u652f\">\u5220\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%8F%90%E4%BA%A4%E4%BB%A3%E7%A0%81\" title=\"\u63d0\u4ea4\u4ee3\u7801\">\u63d0\u4ea4\u4ee3\u7801<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/bestcoder.cn\/git\/#%E7%9C%8B%E5%B7%B2%E4%BF%AE%E6%94%B9%E7%9A%84%E4%BB%A3%E7%A0%81\" title=\"\u770b\u5df2\u4fee\u6539\u7684\u4ee3\u7801\">\u770b\u5df2\u4fee\u6539\u7684\u4ee3\u7801<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%8E%A8%E5%88%86%E6%94%AF\" title=\"\u63a8\u5206\u652f\">\u63a8\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/bestcoder.cn\/git\/#%E4%BB%8E%E6%9A%82%E5%AD%98%E5%8C%BA%E5%A4%8D%E5%8E%9F\" title=\"\u4ece\u6682\u5b58\u533a\u590d\u539f\">\u4ece\u6682\u5b58\u533a\u590d\u539f<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%A4%8D%E6%9D%82%E5%91%BD%E4%BB%A4\" title=\"\u590d\u6742\u547d\u4ee4\">\u590d\u6742\u547d\u4ee4<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/bestcoder.cn\/git\/#rebase%E6%80%BB%E7%BB%93\" title=\"rebase\u603b\u7ed3\">rebase\u603b\u7ed3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/bestcoder.cn\/git\/#commit%E9%94%99%E4%BA%86%E5%9B%9E%E9%80%80%EF%BC%8C%E6%AF%94%E5%A6%82%E6%B2%A1%E5%B8%A6icafe%E7%9A%84id\" title=\"commit\u9519\u4e86\u56de\u9000\uff0c\u6bd4\u5982\u6ca1\u5e26icafe\u7684id\">commit\u9519\u4e86\u56de\u9000\uff0c\u6bd4\u5982\u6ca1\u5e26icafe\u7684id<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%BC%BA%E5%88%B6%E5%A4%8D%E5%8E%9F\" title=\"\u5f3a\u5236\u590d\u539f\">\u5f3a\u5236\u590d\u539f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%BC%BA%E5%88%B6%E8%A6%86%E7%9B%96\" title=\"\u5f3a\u5236\u8986\u76d6\">\u5f3a\u5236\u8986\u76d6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/bestcoder.cn\/git\/#%E9%87%8D%E7%BD%AE%E5%88%B0%E6%9C%80%E6%96%B0%E7%9A%84%E8%BF%9C%E7%AB%AF%E5%88%86%E6%94%AF\" title=\"\u91cd\u7f6e\u5230\u6700\u65b0\u7684\u8fdc\u7aef\u5206\u652f\">\u91cd\u7f6e\u5230\u6700\u65b0\u7684\u8fdc\u7aef\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%90%8C%E6%AD%A5%E4%B8%BB%E5%B9%B2%E5%90%8E%EF%BC%8C%E6%8F%90%E4%BA%A4%E5%8E%86%E5%8F%B2%E5%A4%9A%E5%87%BA%E4%B8%80%E5%A0%86%E6%96%87%E4%BB%B6%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95\" title=\"\u540c\u6b65\u4e3b\u5e72\u540e\uff0c\u63d0\u4ea4\u5386\u53f2\u591a\u51fa\u4e00\u5806\u6587\u4ef6\u7684\u89e3\u51b3\u529e\u6cd5\">\u540c\u6b65\u4e3b\u5e72\u540e\uff0c\u63d0\u4ea4\u5386\u53f2\u591a\u51fa\u4e00\u5806\u6587\u4ef6\u7684\u89e3\u51b3\u529e\u6cd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%94%BE%E5%BC%83%E4%BF%AE%E6%94%B9\" title=\"\u653e\u5f03\u4fee\u6539\">\u653e\u5f03\u4fee\u6539<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/bestcoder.cn\/git\/#%E4%B8%B4%E6%97%B6%E4%BF%9D%E5%AD%98%E4%BF%AE%E6%94%B9%E7%9A%84%E6%96%87%E4%BB%B6\" title=\"\u4e34\u65f6\u4fdd\u5b58\u4fee\u6539\u7684\u6587\u4ef6\">\u4e34\u65f6\u4fdd\u5b58\u4fee\u6539\u7684\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%9B%9E%E9%80%80%E6%9F%90%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6%E7%9A%84%E7%89%88%E6%9C%AC\" title=\"\u56de\u9000\u67d0\u4e00\u4e2a\u6587\u4ef6\u7684\u7248\u672c\">\u56de\u9000\u67d0\u4e00\u4e2a\u6587\u4ef6\u7684\u7248\u672c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/bestcoder.cn\/git\/#git_add_%E6%8E%92%E9%99%A4%E6%9F%90%E4%B8%AA%E6%96%87%E4%BB%B6\" title=\"git add \u6392\u9664\u67d0\u4e2a\u6587\u4ef6\">git add \u6392\u9664\u67d0\u4e2a\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/bestcoder.cn\/git\/#git%E7%9C%8B%E6%9F%90%E4%B8%AA%E6%96%87%E4%BB%B6%E7%9A%84%E4%BF%AE%E6%94%B9%E5%8E%86%E5%8F%B2\" title=\"git\u770b\u67d0\u4e2a\u6587\u4ef6\u7684\u4fee\u6539\u5386\u53f2\">git\u770b\u67d0\u4e2a\u6587\u4ef6\u7684\u4fee\u6539\u5386\u53f2<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%89%B9%E9%87%8F%E5%88%A0%E9%99%A4%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF\" title=\"\u6279\u91cf\u5220\u9664\u672c\u5730\u5206\u652f\">\u6279\u91cf\u5220\u9664\u672c\u5730\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%88%A0%E9%99%A4%E8%BF%9C%E7%AB%AF%E5%B7%B2%E5%88%A0%E9%99%A4%E6%9C%AC%E5%9C%B0%E4%BB%8D%E5%AD%98%E5%9C%A8%E7%9A%84%E5%88%86%E6%94%AF\" title=\"\u5220\u9664\u8fdc\u7aef\u5df2\u5220\u9664\u672c\u5730\u4ecd\u5b58\u5728\u7684\u5206\u652f\">\u5220\u9664\u8fdc\u7aef\u5df2\u5220\u9664\u672c\u5730\u4ecd\u5b58\u5728\u7684\u5206\u652f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/bestcoder.cn\/git\/#git_%E9%85%8D%E7%BD%AE\" title=\"git \u914d\u7f6e\">git \u914d\u7f6e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/bestcoder.cn\/git\/#git_cherry_pick\" title=\"git cherry pick\">git cherry pick<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%8F%96%E6%B6%88merge\" title=\"\u53d6\u6d88merge\">\u53d6\u6d88merge<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%8F%96%E6%B6%88add\" title=\"\u53d6\u6d88add\">\u53d6\u6d88add<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%88%AB%E5%90%8D\" title=\"\u522b\u540d\">\u522b\u540d<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/bestcoder.cn\/git\/#%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E5%88%9B%E5%BB%BA%E6%97%B6%E9%97%B4\" title=\"\u67e5\u770b\u672c\u5730\u5206\u652f\u521b\u5efa\u65f6\u95f4\">\u67e5\u770b\u672c\u5730\u5206\u652f\u521b\u5efa\u65f6\u95f4<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-34\" href=\"https:\/\/bestcoder.cn\/git\/#git_town\" title=\"git town\">git town<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-35\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%B8%B8%E8%A7%81%E7%94%A8%E6%B3%95%EF%BC%88%E4%BD%A0%E5%9F%BA%E6%9C%AC%E6%8A%8A%E5%AE%83%E5%BD%93%E2%80%9C%E5%88%86%E6%94%AF%E5%B7%A5%E4%BD%9C%E6%B5%81%E8%84%9A%E6%89%8B%E6%9E%B6%E2%80%9D%EF%BC%89\" title=\"\u5e38\u89c1\u7528\u6cd5\uff08\u4f60\u57fa\u672c\u628a\u5b83\u5f53\u201c\u5206\u652f\u5de5\u4f5c\u6d41\u811a\u624b\u67b6\u201d\uff09\">\u5e38\u89c1\u7528\u6cd5\uff08\u4f60\u57fa\u672c\u628a\u5b83\u5f53\u201c\u5206\u652f\u5de5\u4f5c\u6d41\u811a\u624b\u67b6\u201d\uff09<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-36\" href=\"https:\/\/bestcoder.cn\/git\/#1_%E5%88%9D%E5%A7%8B%E5%8C%96%E9%85%8D%E7%BD%AE\" title=\"1) \u521d\u59cb\u5316\/\u914d\u7f6e\">1) \u521d\u59cb\u5316\/\u914d\u7f6e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-37\" href=\"https:\/\/bestcoder.cn\/git\/#2_%E6%97%A5%E5%B8%B8%E5%BC%80%E5%8F%91%EF%BC%88%E6%9C%80%E5%B8%B8%E7%94%A8%E7%9A%84%E4%B8%80%E5%A5%97%EF%BC%89\" title=\"2) \u65e5\u5e38\u5f00\u53d1\uff08\u6700\u5e38\u7528\u7684\u4e00\u5957\uff09\">2) \u65e5\u5e38\u5f00\u53d1\uff08\u6700\u5e38\u7528\u7684\u4e00\u5957\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-38\" href=\"https:\/\/bestcoder.cn\/git\/#3_Stacked_changes%EF%BC%88%E5%A0%86%E6%A0%88%E5%88%86%E6%94%AF%EF%BC%8C%E9%80%82%E5%90%88%E2%80%9C%E4%B8%80%E4%B8%AA%E5%A4%A7%E9%9C%80%E6%B1%82%E6%8B%86%E5%A4%9A%E4%B8%AA%E5%B0%8F_PR%E2%80%9D%EF%BC%89\" title=\"3) Stacked changes\uff08\u5806\u6808\u5206\u652f\uff0c\u9002\u5408\u201c\u4e00\u4e2a\u5927\u9700\u6c42\u62c6\u591a\u4e2a\u5c0f PR\u201d\uff09\">3) Stacked changes\uff08\u5806\u6808\u5206\u652f\uff0c\u9002\u5408\u201c\u4e00\u4e2a\u5927\u9700\u6c42\u62c6\u591a\u4e2a\u5c0f PR\u201d\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-39\" href=\"https:\/\/bestcoder.cn\/git\/#4_%E5%87%BA%E9%97%AE%E9%A2%98%E6%97%B6%EF%BC%88%E5%86%B2%E7%AA%81%E4%B8%AD%E6%96%AD%E6%81%A2%E5%A4%8D%EF%BC%89\" title=\"4) \u51fa\u95ee\u9898\u65f6\uff08\u51b2\u7a81\/\u4e2d\u65ad\u6062\u590d\uff09\">4) \u51fa\u95ee\u9898\u65f6\uff08\u51b2\u7a81\/\u4e2d\u65ad\u6062\u590d\uff09<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-40\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%AE%83%E6%98%AF%E4%BB%80%E4%B9%88%E6%97%B6%E5%80%99%E2%80%9C%E5%8F%91%E6%98%8E%E2%80%9D%E7%9A%84%EF%BC%9F\" title=\"\u5b83\u662f\u4ec0\u4e48\u65f6\u5019\u201c\u53d1\u660e\u201d\u7684\uff1f\">\u5b83\u662f\u4ec0\u4e48\u65f6\u5019\u201c\u53d1\u660e\u201d\u7684\uff1f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-41\" href=\"https:\/\/bestcoder.cn\/git\/#%E7%96%91%E9%9A%BE%E6%9D%82%E7%97%87\" title=\"\u7591\u96be\u6742\u75c7\">\u7591\u96be\u6742\u75c7<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-42\" href=\"https:\/\/bestcoder.cn\/git\/#error_cannot_lock_ref_%E2%80%98refsremotes\" title=\"error: cannot lock ref &#8216;refs\/remotes\">error: cannot lock ref &#8216;refs\/remotes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-43\" href=\"https:\/\/bestcoder.cn\/git\/#%E5%88%A0%E9%99%A4third_party\" title=\"\u5220\u9664third_party\">\u5220\u9664third_party<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-44\" href=\"https:\/\/bestcoder.cn\/git\/#git_push_%E4%B8%8D%E4%B8%8A%E5%8E%BB\" title=\"git push \u4e0d\u4e0a\u53bb\">git push \u4e0d\u4e0a\u53bb<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8E%9F%E7%90%86\"><\/span>\u539f\u7406<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5de5\u4f5c\u533a\uff1a\u5c31\u662f\u4f60\u5728\u7535\u8111\u91cc\u80fd\u770b\u5230\u7684\u76ee\u5f55\u3002<\/li>\n\n\n\n<li>\u7248\u672c\u5e93\uff1a\u5de5\u4f5c\u533a\u6709\u4e00\u4e2a\u9690\u85cf\u76ee\u5f55&nbsp;<strong>.git<\/strong>\uff0c\u8fd9\u4e2a\u4e0d\u7b97\u5de5\u4f5c\u533a\uff0c\u800c\u662f Git \u7684\u7248\u672c\u5e93\u3002<\/li>\n\n\n\n<li>\u6682\u5b58\u533a\uff1a\u82f1\u6587\u53eb <strong>stage <\/strong>\u6216 index\u3002\u4e00\u822c\u5b58\u653e\u5728&nbsp;<strong>.git<\/strong>&nbsp;\u76ee\u5f55\u4e0b\u7684 index \u6587\u4ef6\uff08.git\/index\uff09\u4e2d\uff0c\u6240\u4ee5\u6211\u4eec\u628a\u6682\u5b58\u533a\u6709\u65f6\u4e5f\u53eb\u4f5c\u7d22\u5f15\uff08index\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6211\u7684\u7406\u89e3\u662f\uff1a\u4f60\u4fee\u6539\u7684\u6587\u4ef6\u5c31\u50cf\u5b50\u5f39\u3002git add\u5c31\u50cf\u628a\u5b50\u5f39\u586b\u5165\u5f39\u5939\uff0cgit commit\u5c31\u50cf\u4e0a\u819b\uff0c\u51c6\u5907\u53d1\u5c04\uff0cgit push\u5c31\u50cf\u5f00\u67aa\u628a\u5b50\u5f39\u5c04\u51fa\u53bb\uff0c\u53d1\u5c04\u5230\u8fdc\u7aef\u3002<\/strong><\/p>\n\n\n\n<p>\u6709\u65f6\u5019\u4f60\u4f1a\u9047\u5230\u4e00\u4e9b\u5f88\u795e\u5947\u7684\u95ee\u9898\uff0c\u8bd5\u4e86\u5f88\u591a\u547d\u4ee4\u90fd\u6ca1\u6709\u7528\uff0c\u8fd9\u65f6\u5019\u4f60\u5b8c\u5168\u53ef\u4ee5\u5927\u80c6\u4fee\u6539.git\u6587\u4ef6\u5939\u4e0b\u9762\u7684config\u6587\u4ef6\u3002\u4f60\u4f1a\u53d1\u73b0git\u4e0d\u8fc7\u5982\u6b64\u3002<\/p>\n\n\n\n<p>\u53c2\u8003\u6587\u6863<\/p>\n\n\n\n<p><a href=\"https:\/\/www.runoob.com\/git\/git-workspace-index-repo.html\">Git \u5de5\u4f5c\u533a\u3001\u6682\u5b58\u533a\u548c\u7248\u672c\u5e93<\/a> <\/p>\n\n\n\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/96631135\">https:\/\/zhuanlan.zhihu.com\/p\/96631135<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%9F%BA%E7%A1%80%E5%91%BD%E4%BB%A4\"><\/span>\u57fa\u7840\u547d\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8B%89%E5%BA%93%E5%92%8C%E6%9B%B4%E6%96%B0\"><\/span>\u62c9\u5e93\u548c\u66f4\u65b0<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>git clone<\/p>\n\n\n\n<p>git pull<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8B%89%E5%8F%96%E5%88%86%E6%94%AF\"><\/span>\u62c9\u53d6\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git pull --set-upstream origin master \u5c06\u5206\u652f\u548c\u8fdc\u7a0b\u7ed1\u5b9a\uff0c\u4e5f\u53ef\u7528\u4e8epush<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git fetch origin official\/1293m104:official\/1293m104  \u62c9\u5206\u652f\u5e76\u5207\u6362<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote set-branches --add origin main \u62c9\u5355\u4e2a\u5206\u652f<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout -t origin\/main -t, --track set upstream info for new branch<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA%E5%88%86%E6%94%AF\"><\/span>\u521b\u5efa\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout -b user\/jiapengli\/newInterfaceTo104<\/code><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762checkout\u7684\u57fa\u7840\u4e0abranch\u4e00\u4e2a\u81ea\u5df1\u65b0\u7684\u5206\u652f\uff0c\u7136\u540echeckout<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch user\/jiapengli\/createWallet<\/code><\/pre>\n\n\n\n<p>\u7136\u540epush\u5230\u8fdc\u7aef\uff0c\u8fdc\u7aef\u5c31\u6709\u4e86\u8fd9\u4e2a\u5206\u652f<\/p>\n\n\n\n<p>\u5f53\u4f60\u628a\u81ea\u5df1\u7684\u5206\u652f\u5408\u5165\u539f\u7684\u5206\u652f\u7684\u65f6\u5019\uff0c\u624d\u7b97\u4e00\u6b21\u63d0\u4ea4PR\uff0c\u9700\u8981\u6709\u4ebacode review\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E7%9C%8B%E5%88%86%E6%94%AF\"><\/span>\u67e5\u770b\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>git branch<\/p>\n\n\n\n<p>git branch -a \u67e5\u770b\u5168\u90e8\u5206\u652f<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%A0%E6%96%87%E4%BB%B6\"><\/span>\u5220\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git rm\ngit status\ngit add -u\ngit commit<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%87%8D%E7%BD%AE%E4%BB%A3%E7%A0%81\"><\/span>\u91cd\u7f6e\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --hard \u516d\u4f4d\u5b57\u6bcd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%A0%E5%88%86%E6%94%AF\"><\/span>\u5220\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch -D main<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8F%90%E4%BA%A4%E4%BB%A3%E7%A0%81\"><\/span>\u63d0\u4ea4\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git add \u6587\u4ef6<\/code><\/pre>\n\n\n\n<p>\u5728\u63d0\u4ea4\u6700\u540e\u4e00\u4e2a\u4fee\u6539\u7684commit\u4f7f\u7528\u2013amend\u53c2\u6570\uff0c\u8fd9\u65f6\u4e4b\u524d\u7684\u4e00\u4e2acommit\u5c06\u4f1a\u5408\u5e76\u5230\u8fd9\u4e2a\u5373\u5c06\u63d0\u4ea4\u7684commit\u4e2d\u6765\uff0c\u5982\u679c\u5f53\u524d\u63d0\u4ea4\u6709\u6ce8\u91ca\uff0c\u5219\u4ee5\u5f53\u524d\u7684\u6ce8\u91ca\u4e3a\u5408\u5e76\u540e\u7684\u63d0\u4ea4\u7684\u6ce8\u91ca\uff0c\u82e5\u5f53\u524d\u63d0\u4ea4\u6ca1\u6709\u6ce8\u91ca\uff0c\u5219\u4ee5\u4e0a\u4e00\u6b21\u63d0\u4ea4\u7684\u6ce8\u91ca\u4f5c\u4e3a\u5408\u5e76\u540e\u7684\u63d0\u4ea4\u7684\u6ce8\u91ca\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git commit -a --amend -m \"my message here\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git push<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%9C%8B%E5%B7%B2%E4%BF%AE%E6%94%B9%E7%9A%84%E4%BB%A3%E7%A0%81\"><\/span>\u770b\u5df2\u4fee\u6539\u7684\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git status<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8E%A8%E5%88%86%E6%94%AF\"><\/span>\u63a8\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>.git\/config<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;remote \"origin\"]<br>&nbsp;&nbsp;&nbsp;&nbsp;url =&nbsp;<a href=\"https:\/\/microsoft.visualstudio.com\/DefaultCollection\/Edge\/_git\/chromium.src\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/microsoft.visualstudio.com\/DefaultCollection\/Edge\/_git\/chromium.src<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;fetch = +refs\/heads\/*:refs\/remotes\/origin\/*<br>&nbsp;&nbsp;&nbsp;&nbsp;fetch = +refs\/tags\/*:refs\/tags\/*<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BB%8E%E6%9A%82%E5%AD%98%E5%8C%BA%E5%A4%8D%E5%8E%9F\"><\/span>\u4ece\u6682\u5b58\u533a\u590d\u539f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5982\u679c\u4f60add\u4e86 \u60f3\u53d6\u6d88add\ngit reset HEAD\n\u5982\u679c\u4f60commit\u4e86 \u60f3\u53d6\u6d88commit\ngit reset --soft HEAD^<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%A4%8D%E6%9D%82%E5%91%BD%E4%BB%A4\"><\/span>\u590d\u6742\u547d\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"rebase%E6%80%BB%E7%BB%93\"><\/span>rebase\u603b\u7ed3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><p>rebase\u603b\u7ed3\uff1a\n\u4f60\u62c9\u4e86\u4e00\u4e2a\u5206\u652f\uff0c\u5728\u8fd9\u4e2a\u5206\u652f\u4e0a\u5f00\u53d1\u3002\u7136\u540e\u522b\u4eba\u6539\u4e86\u8fd9\u4e2a\u5206\u652f\u7684\u4ee3\u7801\u3002\u5f53\u4f60\u63d0\u4ea4\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u53d1\u751f\u51b2\u7a81\nStep1. \u5728\u672c\u5730\u4ed3\u5e93\u4e2d, \u66f4\u65b0\u5e76\u5408\u5e76\u4ee3\u7801<\/p><p>git fetch origi<span style=\"background-color: inherit; font-family: inherit; font-size: inherit; color: initial;\">n<\/span><\/p><p>git rebase origin\/baby_1-0-1256_BRANCH \u5f00\u53d1\u7684\u5206\u652f<\/p><p>Step2. \u4f9d\u636e\u63d0\u793a\u5206\u522b\u6253\u5f00\u51b2\u7a81\u7684\u6587\u4ef6, \u9010\u4e00\u4fee\u6539\u51b2\u7a81\u4ee3\u7801<\/p><p>Step3. \u6240\u6709\u51b2\u7a81\u90fd\u4fee\u6539\u5b8c\u6bd5\u540e, \u63d0\u4ea4\u4fee\u6539\u7684\u4ee3\u7801<\/p><p>git add -u<\/p><p>git rebase --continue<\/p><p>Step4. \u66f4\u65b0patch<\/p><p>git push origin HEAD:refs\/for\/baby_1-0-1256_BRANCH<\/p><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"commit%E9%94%99%E4%BA%86%E5%9B%9E%E9%80%80%EF%BC%8C%E6%AF%94%E5%A6%82%E6%B2%A1%E5%B8%A6icafe%E7%9A%84id\"><\/span>commit\u9519\u4e86\u56de\u9000\uff0c\u6bd4\u5982\u6ca1\u5e26icafe\u7684id<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --soft HEAD^<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u518d\u6267\u884c<strong>\u63d0\u4ea4\u4ee3\u7801<\/strong>\u5373\u53ef<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%BC%BA%E5%88%B6%E5%A4%8D%E5%8E%9F\"><\/span>\u5f3a\u5236\u590d\u539f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --hard origin\/papi_1-3-1678_BRANCH\uff08\u5206\u652f\uff09<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%BC%BA%E5%88%B6%E8%A6%86%E7%9B%96\"><\/span>\u5f3a\u5236\u8986\u76d6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git fetch --all<br>git reset --hard origin\/main origin\/papi_1-3-1546_BRANCH<br>git pull<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%87%8D%E7%BD%AE%E5%88%B0%E6%9C%80%E6%96%B0%E7%9A%84%E8%BF%9C%E7%AB%AF%E5%88%86%E6%94%AF\"><\/span>\u91cd\u7f6e\u5230\u6700\u65b0\u7684\u8fdc\u7aef\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git fetch origin\ngit reset --hard origin\/main<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%90%8C%E6%AD%A5%E4%B8%BB%E5%B9%B2%E5%90%8E%EF%BC%8C%E6%8F%90%E4%BA%A4%E5%8E%86%E5%8F%B2%E5%A4%9A%E5%87%BA%E4%B8%80%E5%A0%86%E6%96%87%E4%BB%B6%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95\"><\/span>\u540c\u6b65\u4e3b\u5e72\u540e\uff0c\u63d0\u4ea4\u5386\u53f2\u591a\u51fa\u4e00\u5806\u6587\u4ef6\u7684\u89e3\u51b3\u529e\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>git log \u627e\u5230\u540c\u6b65\u4e3b\u5e72\u7684\u90a3\u6b21\u5386\u53f2<br>git reset \u5207\u5230\u90a3\u6b21\u5386\u53f2<br>\u518d\u6b21 git add . \u63d0\u4ea4\u4e00\u6b21<br>\u4e4b\u524d\u7684\u63d0\u4ea4diff\u4f1a\u6d88\u5931\uff0c\u4f1a\u91cd\u65b0\u751f\u6210\u4e00\u4e2adiff\uff0c\u5c31\u53ea\u5269\u4f60\u6539\u7684diff\u4e86<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%94%BE%E5%BC%83%E4%BF%AE%E6%94%B9\"><\/span>\u653e\u5f03\u4fee\u6539<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout .<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%B8%B4%E6%97%B6%E4%BF%9D%E5%AD%98%E4%BF%AE%E6%94%B9%E7%9A%84%E6%96%87%E4%BB%B6\"><\/span>\u4e34\u65f6\u4fdd\u5b58\u4fee\u6539\u7684\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git stash \ngit stash save ''\ngit stash apply 'stash@{0}'\ngit stash list \u5c55\u793astash\u5217\u8868\ngit stash show -p \u663e\u793a\u67d0\u4e2a\u5b58\u50a8\u7684\u6539\u52a8 git stash show stash@{1} \ngit stash drop<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%9B%9E%E9%80%80%E6%9F%90%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6%E7%9A%84%E7%89%88%E6%9C%AC\"><\/span>\u56de\u9000\u67d0\u4e00\u4e2a\u6587\u4ef6\u7684\u7248\u672c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git log \u67d0\u4e2a\u6587\u4ef6 \u6587\u4ef6\u5939<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout &#91;commit id] \u8fd9\u4e2a\u6587\u4ef6<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git commit \uff0cpush \u5373\u53ef<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"git_add_%E6%8E%92%E9%99%A4%E6%9F%90%E4%B8%AA%E6%96%87%E4%BB%B6\"><\/span>git add \u6392\u9664\u67d0\u4e2a\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git add -u -except .\\tmp.txt<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u7528gitignore<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"git%E7%9C%8B%E6%9F%90%E4%B8%AA%E6%96%87%E4%BB%B6%E7%9A%84%E4%BF%AE%E6%94%B9%E5%8E%86%E5%8F%B2\"><\/span>git\u770b\u67d0\u4e2a\u6587\u4ef6\u7684\u4fee\u6539\u5386\u53f2<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git blame \u6587\u4ef6 &gt; tmp.txt<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%89%B9%E9%87%8F%E5%88%A0%E9%99%A4%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF\"><\/span>\u6279\u91cf\u5220\u9664\u672c\u5730\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch|grep -v -E \".<em>(zeshi|code).<\/em>\"| xargs git branch -D<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u81ea\u5df1\u5199\u6b63\u5219\u3002windows\u4e0d\u80fd\u6267\u884cgrep\u5c31\u5728git bash\u91cc\u6267\u884c<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%A0%E9%99%A4%E8%BF%9C%E7%AB%AF%E5%B7%B2%E5%88%A0%E9%99%A4%E6%9C%AC%E5%9C%B0%E4%BB%8D%E5%AD%98%E5%9C%A8%E7%9A%84%E5%88%86%E6%94%AF\"><\/span>\u5220\u9664\u8fdc\u7aef\u5df2\u5220\u9664\u672c\u5730\u4ecd\u5b58\u5728\u7684\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote prune origin\n\nThere are probably some commands to resolve it, but I would start by looking in your .git\/config file for references to that branch, and removing them.<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"996\" src=\"https:\/\/qlili.com\/wp-content\/uploads\/2022\/09\/image-12-1024x996.png\" alt=\"\" class=\"wp-image-3726\" style=\"width:512px;height:498px\" srcset=\"https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/09\/image-12-1024x996.png 1024w, https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/09\/image-12-300x292.png 300w, https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/09\/image-12-768x747.png 768w, https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/09\/image-12.png 1128w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"git_%E9%85%8D%E7%BD%AE\"><\/span>git \u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --local user.name \"\"\ngit config --local user.email \"\"\ngit config --local core.autocrlf false\ngit config --local core.filemode false\ngit config --local branch.autosetuprebase always\ngit config --system core.longpaths true<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"git_cherry_pick\"><\/span>git cherry pick<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u529f\u80fd\uff1a\u5c06\u67d0\u4e2a\u5206\u652f\u7684\u90e8\u5206\u6539\u52a8\uff08\u67d0\u6b21\u63d0\u4ea4\uff09\u5e94\u7528\u5230\u522b\u7684\u5206\u652f\u4e0a <a href=\"https:\/\/www.ruanyifeng.com\/blog\/2020\/04\/git-cherry-pick.html\">\u6559\u7a0b<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6ce8\u610f\u5148\u628a\u5206\u652f\u5207\u5230\u4f60\u60f3cp\u7684\u5206\u652f\uff0c\u5f3a\u5236\u540c\u6b65\u5230\u8fdc\u7aef\uff0c\u7136\u540e\u518d\u5f00\u59cbcp\ngit fetch origin\ngit reset --hard  origin\/official\/1587m110\ngit cherry-pick &lt;commitHash&gt;\ngit cherry-pick A..B A\u65e9\u4e8eB,\u4e0d\u5305\u542bA\ngit cherry-pick A^..B \u5305\u542bA<\/code><\/pre>\n\n\n\n<p>\u4e00\u4e2aPR\u5373\u4fbf\u6709\u591a\u6b21\u63d0\u4ea4\uff0c\u5728main\u5206\u652f\u4e5f\u53ea\u4f1a\u6709\u4e00\u4e2acommit\u3002cherry-pick\u7684\u65f6\u5019\u5728main\u5206\u652f\u627e\u5230\u90a3\u4e2acommit<\/p>\n\n\n\n<p>main\u66f4\u65b0\u540e\uff0c\u9700\u8981pull\u66f4\u65b0\u672c\u5730\u4ee3\u7801\uff0c\u8fd9\u6837cherry-pick\u624d\u77e5\u9053pick\u54ea\u4e9b\u4ee3\u7801<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%96%E6%B6%88merge\"><\/span>\u53d6\u6d88merge<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>rm  \".git\/rebase-merge\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%96%E6%B6%88add\"><\/span>\u53d6\u6d88add<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>add\u7684\u6587\u4ef6\u4f1a\u8fdb\u5165staged change\u3002git reset\u5c31\u80fd\u64a4\u9500\u6389\uff0c\u8ba9\u4ed6\u53d8\u6210change\u72b6\u6001<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%AB%E5%90%8D\"><\/span>\u522b\u540d<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u81ea\u5b9a\u4e49git\u7684\u547d\u4ee4\u3002\u5c31\u6211\u4e2a\u4eba\u7684\u7ecf\u9a8c\uff0c\u7ea6\u4e00\u534a\u7684\u9876\u5c16\u7814\u53d1\u90fd\u4f1a\u81ea\u5b9a\u4e49git<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ git config --global <strong>alias<\/strong>.co checkout\n$ git config --global <strong>alias<\/strong>.ci commit\n$ git config --global <strong>alias<\/strong>.br branch\n  git config --global alias.unstage 'reset HEAD'\n  git config --global alias.last 'log -1'\n  git config --global alias.lg \"log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Creset' --abbrev-commit\"<\/code><\/pre>\n\n\n\n<p>\u672c\u8d28\uff1a\u8fd9\u91cc\u7684\u4fee\u6539\u5176\u5b9e\u90fd\u5728<code>.git\/config<\/code> \u548c .gitconfig\u6587\u4ef6\u4e2d\u3002\u76f4\u63a5\u5728\u8fd9\u91cc\u5220\u9664\/\u4fee\u6539\u5373\u53ef<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"329\" height=\"281\" src=\"https:\/\/qlili.com\/wp-content\/uploads\/2022\/10\/image-18.png\" alt=\"\" class=\"wp-image-4870\" srcset=\"https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/10\/image-18.png 329w, https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/10\/image-18-300x256.png 300w\" sizes=\"auto, (max-width: 329px) 100vw, 329px\" \/><\/figure>\n\n\n\n<p>\u6211\u81ea\u5df1\u7684\u914d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\ngit config --global alias.cl \"clone\"\ngit config --global alias.s \"status\"\ngit config --global alias.d \"diff\"\ngit config --global alias.co \"checkout\"\ngit config --global alias.cmn \"checkout main\"\ngit config --global alias.cmt \"checkout master\"\ngit config --global alias.cmend \"commit --amend --no-edit\"\ngit config --global alias.cb \"checkout -b\"\ngit config --global alias.cbb \"checkout -b user\/jiapengli\/\"\ngit config --global alias.br \"branch\"\ngit config --global alias.last \"log -1 HEAD\"\ngit config --global alias.pr \"pull --rebase\"\ngit config --global alias.lo \"log --oneline -n 10\"\ngit config --global alias.a \"add .\"\ngit config --global alias.am \"commit -a -m add\"\ngit config --global alias.cm \"commit -m\" \ngit config --global alias.cma \"commit -m add\"\ngit config --global alias.cmf \"commit -m fix\"\ngit config --global alias.rh \"reset --hard\"\n\/\/git config --global alias.unstage 'reset HEAD'\ngit config --global alias.rs \"reset --soft HEAD^\"\ngit config --global alias.ps \"push\"\ngit config --global alias.pl \"pull\"\ngit config --global alias.pll \"pull --set-upstream origin master\"\ngit config --global alias.fo \"fetch origin \"\ngit config --global alias.ra \"remote set-branches --add origin \"\/\/\u62c9\u5355\u4e2a\u5206\u652f\ngit config --global alias.pso \"push --set-upstream origin \"\ngit config --global alias.mo \"merge origin\/\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E5%88%9B%E5%BB%BA%E6%97%B6%E9%97%B4\"><\/span>\u67e5\u770b\u672c\u5730\u5206\u652f\u521b\u5efa\u65f6\u95f4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog show --date=iso &lt;branch name><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"git_town\"><\/span>git town<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Git Town\uff08\u547d\u4ee4\u662f <code>git town ...<\/code>\uff09\u672c\u8d28\u4e0a\u662f<strong>\u4e00\u5c42\u201c\u9ad8\u9636 Git \u5de5\u4f5c\u6d41 CLI\u201d<\/strong>\uff1a\u628a\u4f60\u5e73\u65f6\u505a\u5206\u652f\u521b\u5efa\/\u540c\u6b65\/\u63d0 PR\/\u6e05\u7406\u5206\u652f\u7b49\u4e00\u4e32 Git \u64cd\u4f5c\uff0c\u5c01\u88c5\u6210\u66f4\u5c11\u3001\u66f4\u4e00\u81f4\u7684\u547d\u4ee4\uff0c\u7528\u6765\u51cf\u5c11\u624b\u5de5\u6b65\u9aa4\u548c\u51fa\u9519\u6982\u7387\u3002\u5b83\u652f\u6301 GitHub Flow \/ Git Flow \/ trunk-based \/ stacked changes \u7b49\u5e38\u89c1\u5206\u652f\u6a21\u578b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%B8%B8%E8%A7%81%E7%94%A8%E6%B3%95%EF%BC%88%E4%BD%A0%E5%9F%BA%E6%9C%AC%E6%8A%8A%E5%AE%83%E5%BD%93%E2%80%9C%E5%88%86%E6%94%AF%E5%B7%A5%E4%BD%9C%E6%B5%81%E8%84%9A%E6%89%8B%E6%9E%B6%E2%80%9D%EF%BC%89\"><\/span>\u5e38\u89c1\u7528\u6cd5\uff08\u4f60\u57fa\u672c\u628a\u5b83\u5f53\u201c\u5206\u652f\u5de5\u4f5c\u6d41\u811a\u624b\u67b6\u201d\uff09<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_%E5%88%9D%E5%A7%8B%E5%8C%96%E9%85%8D%E7%BD%AE\"><\/span>1) \u521d\u59cb\u5316\/\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>git town init<\/code>\uff1a\u8dd1\u4e00\u904d\u4ea4\u4e92\u5f0f\u521d\u59cb\u5316\uff08\u9009\u62e9\u4e3b\u5206\u652f\u3001perennial \u5206\u652f\u3001push\/pull \u884c\u4e3a\u7b49\uff09<\/li>\n\n\n\n<li><code>git town config<\/code>\uff1a\u67e5\u770b\/\u4fee\u6539 Git Town \u914d\u7f6e<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_%E6%97%A5%E5%B8%B8%E5%BC%80%E5%8F%91%EF%BC%88%E6%9C%80%E5%B8%B8%E7%94%A8%E7%9A%84%E4%B8%80%E5%A5%97%EF%BC%89\"><\/span>2) \u65e5\u5e38\u5f00\u53d1\uff08\u6700\u5e38\u7528\u7684\u4e00\u5957\uff09<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>git town hack &lt;name><\/code>\uff1a\u4ece main\uff08\u6216\u4f60\u7684\u4e3b\u5206\u652f\uff09\u62c9\u4e00\u6761<strong>\u5e72\u51c0\u3001\u6700\u65b0<\/strong>\u7684 feature \u5206\u652f<\/li>\n\n\n\n<li>\u6b63\u5e38 <code>git commit<\/code>\uff08Git Town\u4e0d\u66ff\u4ee3commit\u672c\u8eab\uff09<\/li>\n\n\n\n<li><code>git town sync<\/code>\uff1a\u628a\u4f60\u7684\u5206\u652f\/\u5806\u6808\u5206\u652f<strong>\u6574\u4f53\u540c\u6b65<\/strong>\uff08\u62c9\u8fdc\u7aef\u3001rebase\/merge \u6309\u914d\u7f6e\u8d70\u3001\u5fc5\u8981\u65f6\u6e05\u7406\u5df2\u5408\u5e76\u5206\u652f\u7b49\uff09<\/li>\n\n\n\n<li><code>git town propose<\/code>\uff1a\u7ed9\u5f53\u524d\u5206\u652f\u521b\u5efa PR\/MR\uff08\u5bf9\u63a5 GitHub\/GitLab \u7b49\uff09<\/li>\n\n\n\n<li>\u5408\u5e76\u540e\uff1a\n<ul class=\"wp-block-list\">\n<li><code>git town delete<\/code> \/ <code>git town ship<\/code>\uff1a\u6e05\u7406\/\u201c\u53d1\u8d27\u201d\uff08\u5f88\u591a\u56e2\u961f\u66f4\u63a8\u8350\u5728\u7f51\u9875\/merge queue \u5408\u5e76\uff0cGit Town\u8d1f\u8d23\u6574\u7406\u672c\u5730\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Stacked_changes%EF%BC%88%E5%A0%86%E6%A0%88%E5%88%86%E6%94%AF%EF%BC%8C%E9%80%82%E5%90%88%E2%80%9C%E4%B8%80%E4%B8%AA%E5%A4%A7%E9%9C%80%E6%B1%82%E6%8B%86%E5%A4%9A%E4%B8%AA%E5%B0%8F_PR%E2%80%9D%EF%BC%89\"><\/span>3) Stacked changes\uff08\u5806\u6808\u5206\u652f\uff0c\u9002\u5408\u201c\u4e00\u4e2a\u5927\u9700\u6c42\u62c6\u591a\u4e2a\u5c0f PR\u201d\uff09<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>git town append<\/code> \/ <code>prepend<\/code>\uff1a\u5728\u5f53\u524d\u5206\u652f\u4e0a\u201c\u5f80\u4e0a\/\u5f80\u4e0b\u201d\u63d2\u5165\u5b50\u5206\u652f\/\u7236\u5206\u652f<\/li>\n\n\n\n<li><code>git town set-parent<\/code> \/ <code>swap<\/code> \/ <code>detach<\/code>\uff1a\u8c03\u6574\u5806\u6808\u5173\u7cfb<\/li>\n\n\n\n<li><code>git town diff-parent<\/code>\uff1a\u770b\u5f53\u524d\u5206\u652f\u76f8\u5bf9\u7236\u5206\u652f\u7684\u5dee\u5f02<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_%E5%87%BA%E9%97%AE%E9%A2%98%E6%97%B6%EF%BC%88%E5%86%B2%E7%AA%81%E4%B8%AD%E6%96%AD%E6%81%A2%E5%A4%8D%EF%BC%89\"><\/span>4) \u51fa\u95ee\u9898\u65f6\uff08\u51b2\u7a81\/\u4e2d\u65ad\u6062\u590d\uff09<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>git town continue<\/code>\uff1a\u89e3\u51b3\u51b2\u7a81\u540e\u7ee7\u7eed\u8dd1\u5b8c<\/li>\n\n\n\n<li><code>git town undo<\/code>\uff1a\u64a4\u9500\u4e0a\u4e00\u6b21 Git Town \u64cd\u4f5c<\/li>\n\n\n\n<li><code>git town runlog<\/code>\uff1a\u770b\u5b83\u521a\u624d\u505a\u4e86\u54ea\u4e9b\u4e8b\uff08\u4fbf\u4e8e\u6392\u969c\uff09<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%83%E6%98%AF%E4%BB%80%E4%B9%88%E6%97%B6%E5%80%99%E2%80%9C%E5%8F%91%E6%98%8E%E2%80%9D%E7%9A%84%EF%BC%9F\"><\/span>\u5b83\u662f\u4ec0\u4e48\u65f6\u5019\u201c\u53d1\u660e\u201d\u7684\uff1f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u4ece Git Town \u81ea\u5df1\u7684\u53d8\u66f4\u8bb0\u5f55\u91cc\u53ef\u4ee5\u770b\u5230<strong>\u6700\u65e9\u7684\u7248\u672c\u53f7\u8bb0\u5f55\u4e3a <code>0.1.0 (2014-05-22)<\/code><\/strong>\uff0c\u56e0\u6b64\u5b83\u81f3\u5c11\u5728 <strong>2014 \u5e74 5 \u6708<\/strong>\u5c31\u5df2\u7ecf\u51fa\u73b0\u5e76\u53d1\u5e03\u4e86\u65e9\u671f\u7248\u672c\u3002<br>\u5b83\u5728\u5f00\u53d1\u8005\u793e\u533a\u91cc\u88ab\u66f4\u5e7f\u6cdb\u8ba8\u8bba\/\u4f20\u64ad\u5927\u6982\u662f <strong>2017 \u5e74<\/strong>\u5de6\u53f3\uff08\u6bd4\u5982 Hacker News \u4e0a\u7684\u8ba8\u8bba\u5e16\uff09\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%96%91%E9%9A%BE%E6%9D%82%E7%97%87\"><\/span>\u7591\u96be\u6742\u75c7<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"error_cannot_lock_ref_%E2%80%98refsremotes\"><\/span>error: cannot lock ref &#8216;refs\/remotes<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>PS D:\\xpay&gt; git fetch<br>error: cannot lock ref &#8216;refs\/remotes\/origin\/Release_XPay&#8217;: is at e71803a055b13b28e3e2e0037422234d57973da3 but expected cd71d076cbaeb8f1e064b4eea577cd7eab1879dd<br>From https:\/\/dev.azure.com\/msasg\/XPay\/_git\/xpay<br>! cd71d076cb\u20260e113240bd Release_XPay -&gt; origin\/Release_XPay (unable to update local ref)<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u95ee\u9898\u901a\u5e38\u662f\u7531\u4e8e\u672c\u5730\u4ed3\u5e93\u4e2d\u7684\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\u5f15\u7528\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u5b9e\u9645\u4e0a\u7684\u72b6\u6001\u4e0d\u540c\u6b65\u6240\u5bfc\u81f4\u7684\u3002\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u65b9\u6cd5\u4e4b\u4e00\u662f\u5220\u9664\u672c\u5730\u7684\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\u5f15\u7528\uff0c\u7136\u540e\u518d\u6b21\u6267\u884c <code>git fetch<\/code> \u6765\u91cd\u65b0\u83b7\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u72b6\u6001\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5220\u9664\u672c\u5730\u7684\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\u5f15\u7528\uff1a<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<br>git update-ref -d refs\/remotes\/origin\/Release_XPay<\/p>\n\n\n\n<p><code>git update-ref<\/code> \u547d\u4ee4\u7528\u4e8e\u521b\u5efa\u3001\u66f4\u65b0\u3001\u5220\u9664\u3001\u9a8c\u8bc1\u548c\u67e5\u770b\u5f15\u7528\u3002\u5728\u8fd9\u4e2a\u7279\u5b9a\u7684\u547d\u4ee4 <code>git update-ref -d refs\/remotes\/origin\/Release_XPay<\/code> \u4e2d\uff0c\u9009\u9879\u548c\u53c2\u6570\u7684\u542b\u4e49\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-d<\/code>\uff1a\u8fd9\u662f <code>--delete<\/code> \u7684\u7f29\u5199\u5f62\u5f0f\uff0c\u5b83\u6307\u793a <code>git update-ref<\/code> \u5220\u9664\u6307\u5b9a\u7684\u5f15\u7528\u3002<\/li>\n\n\n\n<li><code>refs\/remotes\/origin\/Release_XPay<\/code>\uff1a\u8fd9\u662f\u8981\u5220\u9664\u7684\u5f15\u7528\u7684\u5b8c\u6574\u8def\u5f84\u3002\u5728 Git \u4e2d\uff0c<code>refs\/remotes\/origin\/<\/code> \u662f\u5b58\u50a8\u8fdc\u7a0b\u4ed3\u5e93 <code>origin<\/code> \u5f15\u7528\u7684\u672c\u5730\u76ee\u5f55\u3002<code>Release_XPay<\/code> \u662f\u8fdc\u7a0b\u5206\u652f\u7684\u540d\u79f0\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u7efc\u5408\u8d77\u6765\uff0c\u8fd9\u4e2a\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4ece\u672c\u5730 Git \u4ed3\u5e93\u4e2d\u5220\u9664 <code>Release_XPay<\/code> \u8fd9\u4e2a\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\u7684\u5f15\u7528\u3002\u8fd9\u901a\u5e38\u7528\u4e8e\u89e3\u51b3\u5f53\u8fdc\u7a0b\u5206\u652f\u7684\u5386\u53f2\u4e0e\u672c\u5730\u7f13\u5b58\u7684\u5386\u53f2\u4e0d\u4e00\u81f4\u65f6\u7684\u95ee\u9898\u3002\u5220\u9664\u5f15\u7528\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>git fetch<\/code> \u547d\u4ee4\u91cd\u65b0\u83b7\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u72b6\u6001\uff0c\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u3001\u6700\u65b0\u7684\u5f15\u7528\u3002<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6848 2<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>git fetch &#8211;prune origin&nbsp;&nbsp; &nbsp;update local copies of remote branches<\/li>\n\n\n\n<li>git remote prune origin&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remove info about removed remote branches<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%A0%E9%99%A4third_party\"><\/span>\u5220\u9664third_party<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout &lt;commit&gt; -- \/xxx\/folder\ncommit\u53ef\u4ee5\u662f origin\/main\n\n\u6709\u65f6\u5019\u8fdc\u7aef\u4f1a\u591a\u51fa\u4e00\u4e9b\u672c\u5730\u6ca1\u6709\u7684\u6587\u4ef6\uff0c\u9700\u8981\u5220\u6389\u3002\n\u5207\u5230git bash\nrm -rf third_party\u6587\u4ef6\u5939\ngit rm third_party\u6587\u4ef6\u5939\ngit a\ngit commit \u6ce8\u610f\u53ea\u662fcommit\ngit ps<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"git_push_%E4%B8%8D%E4%B8%8A%E5%8E%BB\"><\/span>git push \u4e0d\u4e0a\u53bb<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u770b\u4e0b\u662f\u4e0d\u662f\u516c\u53f8\u5f39\u51fa\u7684git\u767b\u5f55\u7a97\u53e3\u6ca1\u6709\u767b\u5f55<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u7ba1\u7406<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[21],"tags":[],"class_list":["post-521","post","type-post","status-publish","format-standard","hentry","category-computer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>git\u539f\u7406\u548c\u547d\u4ee4 - \u9876\u5c16\u7814\u53d1<\/title>\n<meta name=\"description\" content=\"git\u539f\u7406\u548c\u547d\u4ee4 \u4ee3\u7801\u7ba1\u7406 - \u8ba1\u7b97\u673a  bestcoder\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bestcoder.cn\/git\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"git\u539f\u7406\u548c\u547d\u4ee4 - \u9876\u5c16\u7814\u53d1\" \/>\n<meta property=\"og:description\" content=\"git\u539f\u7406\u548c\u547d\u4ee4 \u4ee3\u7801\u7ba1\u7406 - \u8ba1\u7b97\u673a  bestcoder\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bestcoder.cn\/git\" \/>\n<meta property=\"og:site_name\" content=\"\u9876\u5c16\u7814\u53d1\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-20T03:30:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-03T08:31:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/09\/image-12.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1128\" \/>\n\t<meta property=\"og:image:height\" content=\"1097\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"qlili\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"qlili\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git\"},\"author\":{\"name\":\"qlili\",\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/#\\\/schema\\\/person\\\/ca3bbfb071c1ffa1c51288eda05b6fd4\"},\"headline\":\"git\u539f\u7406\u548c\u547d\u4ee4\",\"datePublished\":\"2022-02-20T03:30:52+00:00\",\"dateModified\":\"2026-03-03T08:31:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git\"},\"wordCount\":252,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/#\\\/schema\\\/person\\\/ca3bbfb071c1ffa1c51288eda05b6fd4\"},\"image\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/qlili.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/image-12-1024x996.png\",\"articleSection\":[\"\u8ba1\u7b97\u673a\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/bestcoder.cn\\\/git#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git\",\"url\":\"https:\\\/\\\/bestcoder.cn\\\/git\",\"name\":\"git\u539f\u7406\u548c\u547d\u4ee4 - \u9876\u5c16\u7814\u53d1\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/qlili.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/image-12-1024x996.png\",\"datePublished\":\"2022-02-20T03:30:52+00:00\",\"dateModified\":\"2026-03-03T08:31:46+00:00\",\"description\":\"git\u539f\u7406\u548c\u547d\u4ee4 \u4ee3\u7801\u7ba1\u7406 - \u8ba1\u7b97\u673a bestcoder\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/bestcoder.cn\\\/git\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git#primaryimage\",\"url\":\"https:\\\/\\\/qlili.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/image-12-1024x996.png\",\"contentUrl\":\"https:\\\/\\\/qlili.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/image-12-1024x996.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/git#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/bestcoder.cn\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"git\u539f\u7406\u548c\u547d\u4ee4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/#website\",\"url\":\"https:\\\/\\\/bestcoder.cn\\\/\",\"name\":\"\u9876\u5c16\u7814\u53d1\\\/\u9876\u7ea7\u7814\u53d1\\\/\u7814\u53d1\",\"description\":\"bestcoder\",\"publisher\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/#\\\/schema\\\/person\\\/ca3bbfb071c1ffa1c51288eda05b6fd4\"},\"alternateName\":\"\u9876\u5c16\u7814\u53d1\\\/\u9876\u7ea7\u7814\u53d1\\\/\u7814\u53d1 \u4e16\u754c\u7ea7\u9876\u5c16\u7814\u53d1 \u4e2d\u56fd\u6700\u9876\u5c16\u7a0b\u5e8f\u5458\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/bestcoder.cn\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/#\\\/schema\\\/person\\\/ca3bbfb071c1ffa1c51288eda05b6fd4\",\"name\":\"qlili\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg\",\"url\":\"https:\\\/\\\/bestcoder.cn\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg\",\"contentUrl\":\"https:\\\/\\\/bestcoder.cn\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg\",\"width\":512,\"height\":512,\"caption\":\"qlili\"},\"logo\":{\"@id\":\"https:\\\/\\\/bestcoder.cn\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg\"},\"sameAs\":[\"https:\\\/\\\/bestcoder.cn\"],\"url\":\"https:\\\/\\\/bestcoder.cn\\\/author\\\/jax\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"git\u539f\u7406\u548c\u547d\u4ee4 - \u9876\u5c16\u7814\u53d1","description":"git\u539f\u7406\u548c\u547d\u4ee4 \u4ee3\u7801\u7ba1\u7406 - \u8ba1\u7b97\u673a  bestcoder","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bestcoder.cn\/git","og_locale":"en_US","og_type":"article","og_title":"git\u539f\u7406\u548c\u547d\u4ee4 - \u9876\u5c16\u7814\u53d1","og_description":"git\u539f\u7406\u548c\u547d\u4ee4 \u4ee3\u7801\u7ba1\u7406 - \u8ba1\u7b97\u673a  bestcoder","og_url":"https:\/\/bestcoder.cn\/git","og_site_name":"\u9876\u5c16\u7814\u53d1","article_published_time":"2022-02-20T03:30:52+00:00","article_modified_time":"2026-03-03T08:31:46+00:00","og_image":[{"width":1128,"height":1097,"url":"https:\/\/bestcoder.cn\/wp-content\/uploads\/2022\/09\/image-12.png","type":"image\/png"}],"author":"qlili","twitter_card":"summary_large_image","twitter_misc":{"Written by":"qlili","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/bestcoder.cn\/git#article","isPartOf":{"@id":"https:\/\/bestcoder.cn\/git"},"author":{"name":"qlili","@id":"https:\/\/bestcoder.cn\/#\/schema\/person\/ca3bbfb071c1ffa1c51288eda05b6fd4"},"headline":"git\u539f\u7406\u548c\u547d\u4ee4","datePublished":"2022-02-20T03:30:52+00:00","dateModified":"2026-03-03T08:31:46+00:00","mainEntityOfPage":{"@id":"https:\/\/bestcoder.cn\/git"},"wordCount":252,"commentCount":2,"publisher":{"@id":"https:\/\/bestcoder.cn\/#\/schema\/person\/ca3bbfb071c1ffa1c51288eda05b6fd4"},"image":{"@id":"https:\/\/bestcoder.cn\/git#primaryimage"},"thumbnailUrl":"https:\/\/qlili.com\/wp-content\/uploads\/2022\/09\/image-12-1024x996.png","articleSection":["\u8ba1\u7b97\u673a"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/bestcoder.cn\/git#respond"]}]},{"@type":"WebPage","@id":"https:\/\/bestcoder.cn\/git","url":"https:\/\/bestcoder.cn\/git","name":"git\u539f\u7406\u548c\u547d\u4ee4 - \u9876\u5c16\u7814\u53d1","isPartOf":{"@id":"https:\/\/bestcoder.cn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bestcoder.cn\/git#primaryimage"},"image":{"@id":"https:\/\/bestcoder.cn\/git#primaryimage"},"thumbnailUrl":"https:\/\/qlili.com\/wp-content\/uploads\/2022\/09\/image-12-1024x996.png","datePublished":"2022-02-20T03:30:52+00:00","dateModified":"2026-03-03T08:31:46+00:00","description":"git\u539f\u7406\u548c\u547d\u4ee4 \u4ee3\u7801\u7ba1\u7406 - \u8ba1\u7b97\u673a bestcoder","breadcrumb":{"@id":"https:\/\/bestcoder.cn\/git#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bestcoder.cn\/git"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bestcoder.cn\/git#primaryimage","url":"https:\/\/qlili.com\/wp-content\/uploads\/2022\/09\/image-12-1024x996.png","contentUrl":"https:\/\/qlili.com\/wp-content\/uploads\/2022\/09\/image-12-1024x996.png"},{"@type":"BreadcrumbList","@id":"https:\/\/bestcoder.cn\/git#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/bestcoder.cn\/"},{"@type":"ListItem","position":2,"name":"git\u539f\u7406\u548c\u547d\u4ee4"}]},{"@type":"WebSite","@id":"https:\/\/bestcoder.cn\/#website","url":"https:\/\/bestcoder.cn\/","name":"\u9876\u5c16\u7814\u53d1\/\u9876\u7ea7\u7814\u53d1\/\u7814\u53d1","description":"bestcoder","publisher":{"@id":"https:\/\/bestcoder.cn\/#\/schema\/person\/ca3bbfb071c1ffa1c51288eda05b6fd4"},"alternateName":"\u9876\u5c16\u7814\u53d1\/\u9876\u7ea7\u7814\u53d1\/\u7814\u53d1 \u4e16\u754c\u7ea7\u9876\u5c16\u7814\u53d1 \u4e2d\u56fd\u6700\u9876\u5c16\u7a0b\u5e8f\u5458","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bestcoder.cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/bestcoder.cn\/#\/schema\/person\/ca3bbfb071c1ffa1c51288eda05b6fd4","name":"qlili","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bestcoder.cn\/wp-content\/uploads\/2024\/05\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg","url":"https:\/\/bestcoder.cn\/wp-content\/uploads\/2024\/05\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg","contentUrl":"https:\/\/bestcoder.cn\/wp-content\/uploads\/2024\/05\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg","width":512,"height":512,"caption":"qlili"},"logo":{"@id":"https:\/\/bestcoder.cn\/wp-content\/uploads\/2024\/05\/cropped-cgi-bin_mmwebwx-bin_webwxgetmsgimg__MsgID2002316305218849600skey@crypt_d031e9e3_41028a62119ba053e9dcba2f62216f0fmmweb_appidwx_webfilehelper.jpg"},"sameAs":["https:\/\/bestcoder.cn"],"url":"https:\/\/bestcoder.cn\/author\/jax\/"}]}},"modified_by":"qlili","_links":{"self":[{"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/posts\/521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/comments?post=521"}],"version-history":[{"count":66,"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/posts\/521\/revisions"}],"predecessor-version":[{"id":9484,"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/posts\/521\/revisions\/9484"}],"wp:attachment":[{"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/media?parent=521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/categories?post=521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bestcoder.cn\/wp-json\/wp\/v2\/tags?post=521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}