{"id":19150,"date":"2024-11-19T17:49:57","date_gmt":"2024-11-19T09:49:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19150\/"},"modified":"2024-11-19T17:49:57","modified_gmt":"2024-11-19T09:49:57","slug":"%e6%80%bb%e7%bb%93%e5%88%86%e6%9e%90git-pull-%e5%b8%b8%e8%a7%81%e7%9a%84%e9%94%99%e8%af%af%e5%8f%8a%e5%85%b6%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19150\/","title":{"rendered":"\u603b\u7ed3\u5206\u6790Git pull \u5e38\u89c1\u7684\u9519\u8bef\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"<p>\u5728\u4f7f\u7528 git \u8fdb\u884c\u9879\u76ee\u534f\u4f5c\u65f6\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u4f7f\u7528 git pull \u547d\u4ee4\u6765\u540c\u6b65\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u4ee3\u7801\u5230\u672c\u5730\u3002\u5c3d\u7ba1\u8fd9\u4e2a\u547d\u4ee4\u975e\u5e38\u7b80\u5355\u6613\u7528\uff0c\u4f46\u6709\u65f6\u5019\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u9519\u8bef\uff0c\u751a\u81f3\u5bfc\u81f4\u9879\u76ee\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u3002\u672c\u6587\u5c06\u5206\u6790 git pull \u5e38\u89c1\u7684\u9519\u8bef\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n<p>\u4e00\u3001\u9519\u8bef\u4fe1\u606f<\/p>\n<ol>\n<li>error: Your local changes to &#8216;file-name&#8217; would be overwritten by merge<\/li>\n<\/ol>\n<p>\u8fd9\u662f\u56e0\u4e3a\u6709\u672c\u5730\u4ee3\u7801\u6ca1\u6709\u63d0\u4ea4\uff0c\u4f1a\u5bfc\u81f4 Git pull \u5408\u5e76\u4ee3\u7801\u65f6\u51fa\u73b0\u51b2\u7a81\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u5148\u5c06\u672c\u5730\u4fee\u6539\u63d0\u4ea4\uff0c\u6216\u8005\u4f7f\u7528 git stash \u547d\u4ee4\u5c06\u4fee\u6539\u7f13\u5b58\u8d77\u6765\uff0c\u518d\u4f7f\u7528 git pull \uff0c\u6700\u540e\u5408\u5e76\u4ee3\u7801\u3002<\/p>\n<ol>\n<li>error: The following untracked working tree files would be overwritten by merge<\/li>\n<\/ol>\n<p>\u8fd9\u4e2a\u9519\u8bef\u662f\u56e0\u4e3a\u4f60\u5728\u672c\u5730\u521b\u5efa\u4e86\u65b0\u6587\u4ef6\u6216\u4fee\u6539\u6587\u4ef6\uff0c\u8fd9\u4e9b\u6587\u4ef6\u6ca1\u6709\u88ab Git \u8ddf\u8e2a\uff0c\u4e5f\u6ca1\u6709\u8fdb\u884c git add \u64cd\u4f5c\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u7528 git stash \u547d\u4ee4\u5c06\u8fd9\u4e9b\u4fee\u6539\u7f13\u5b58\uff0c\u5728\u4f7f\u7528 git pull \u540e\u518d\u4f7f\u7528 git stash pop \u547d\u4ee4\u6062\u590d\u4fee\u6539\u3002<\/p>\n<ol>\n<li>error: Your local changes to &#8216;file-name&#8217; would be lost<\/li>\n<\/ol>\n<p>\u8fd9\u4e2a\u9519\u8bef\u662f\u56e0\u4e3a\u672c\u5730\u4ee3\u7801\u505a\u4e86\u4fee\u6539\uff0c\u4f46\u6ca1\u6709\u63d0\u4ea4\uff0c\u8981\u5148\u63d0\u4ea4\u4fee\u6539\u540e\u518d\u8fdb\u884c git pull\u3002<\/p>\n<ol>\n<li>error: cannot pull with rebase: You have unstaged changes<\/li>\n<\/ol>\n<p>\u8fd9\u79cd\u9519\u8bef\u662f Git pull \u7528 rebase \u6a21\u5f0f\u5408\u5e76\u4ee3\u7801\u65f6\u51fa\u73b0\u7684\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u4f7f\u7528 git stash \u547d\u4ee4\u5c06\u4fee\u6539\u7f13\u5b58\u540e\u518d\u5c1d\u8bd5 git pull \u64cd\u4f5c\u3002<\/p>\n<ol>\n<li>error: cannot pull with rebase: You have uncommitted changes<\/li>\n<\/ol>\n<p>\u8fd9\u4e2a\u9519\u8bef\u7684\u539f\u56e0\u548c\u7b2c 4 \u79cd\u9519\u8bef\u4e00\u6837\uff0c\u90fd\u662f\u56e0\u4e3a Git pull \u5728\u4f7f\u7528 rebase \u6a21\u5f0f\u5408\u5e76\u4ee3\u7801\u65f6\u51fa\u73b0\u7684\u3002\u89e3\u51b3\u65b9\u6cd5\u4e5f\u662f\u4f7f\u7528 git stash \u547d\u4ee4\u5c06\u4fee\u6539\u7f13\u5b58\u540e\u518d\u5c1d\u8bd5 git pull \u64cd\u4f5c\u3002<\/p>\n<ol>\n<li>error: could not detach HEAD<\/li>\n<\/ol>\n<p>\u8fd9\u4e2a\u9519\u8bef\u662f\u7531\u4e8e Git pull \u64cd\u4f5c\u4e2d\u4f7f\u7528\u4e86 &#8211;rebase \u6216 &#8211;merge \u53c2\u6570\u5bfc\u81f4\uff0c\u548c\u5f53\u524d HEAD \u5904\u4e8e\u201c\u5206\u79bb\u72b6\u6001\u201d\u6709\u5173\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u5c06\u672c\u5730\u5206\u652f\u5207\u6362\u5230\u4e00\u4e2a\u6b63\u786e\u7684\u7248\u672c\u3002<\/p>\n<ol>\n<li>error: Failed to merge in the changes.<\/li>\n<\/ol>\n<p>\u8fd9\u662f\u56e0\u4e3a Git pull \u540e\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u5408\u5e76\u9020\u6210\u7684\u9519\u8bef\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u624b\u52a8\u89e3\u51b3\u51b2\u7a81\uff0c\u5373\u4fee\u6539\u6587\u4ef6\uff0c\u89e3\u51b3\u51b2\u7a81\u540e\u518d\u8fdb\u884c git add \u548c git commit \u64cd\u4f5c\u3002<\/p>\n<p>\u4e8c\u3001\u89e3\u51b3\u65b9\u6cd5<\/p>\n<ol>\n<li>\u6e05\u7406\u7f13\u5b58\uff1a\u5728\u4f7f\u7528 git pull \u547d\u4ee4\u524d\uff0c\u5148\u6267\u884c git stash \u547d\u4ee4\u5c06\u672c\u5730\u4fee\u6539\u7f13\u5b58\u8d77\u6765\u3002\u7528\u5b8c git pull \u540e\u518d\u6267\u884c git stash pop \u547d\u4ee4\u6062\u590d\u4fee\u6539\u3002<\/li>\n<li>\u63d0\u4ea4\u672c\u5730\u4fee\u6539\uff1a\u5c06\u672c\u5730\u4fee\u6539\u7684\u6587\u4ef6\u5148\u63d0\u4ea4\u5230\u672c\u5730\u5206\u652f\u4e0a\uff0c\u518d\u6267\u884c git pull \u547d\u4ee4\u3002<\/li>\n<li>\u5207\u6362\u5206\u652f\uff1a\u5982\u679c\u51fa\u73b0\u4e86 HEAD \u5904\u4e8e\u201c\u5206\u79bb\u72b6\u6001\u201d\u7684\u9519\u8bef\uff0c\u9700\u8981\u5c06\u672c\u5730\u5206\u652f\u5207\u6362\u5230\u6b63\u786e\u7684\u7248\u672c\u4e0a\u3002<\/li>\n<li>\u89e3\u51b3\u51b2\u7a81\uff1a\u624b\u52a8\u4fee\u6539\u6709\u51b2\u7a81\u7684\u4ee3\u7801\uff0c\u5728\u89e3\u51b3\u5b8c\u51b2\u7a81\u540e\u518d\u8fdb\u884c git add \u548c git commit \u64cd\u4f5c\u3002<\/li>\n<\/ol>\n<p>\u603b\u7ed3<\/p>\n<p>\u5728 Git \u534f\u4f5c\u4e2d\uff0cGit pull \u547d\u4ee4\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u4f46\u662f\u6211\u4eec\u4e5f\u5fc5\u987b\u8ba4\u8bc6\u5230 Git pull \u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u9519\u8bef\uff0c\u4ee5\u4fbf\u6211\u4eec\u80fd\u591f\u66f4\u6709\u6548\u5730\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002\u603b\u7684\u6765\u8bf4\uff0c\u9047\u5230\u9519\u8bef\u4e0d\u8981\u60ca\u614c\u5931\u63aa\uff0c\u5e94\u8be5\u6839\u636e\u9519\u8bef\u539f\u56e0\u91c7\u53d6\u76f8\u5e94\u7684\u63aa\u65bd\uff0c\u4ee5\u4fbf\u6211\u4eec\u7684\u4ee3\u7801\u5408\u5e76\u987a\u5229\u65e0\u963b\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u603b\u7ed3\u5206\u6790Git pull \u5e38\u89c1\u7684\u9519\u8bef\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4f7f\u7528 git \u8fdb\u884c\u9879\u76ee\u534f\u4f5c\u65f6\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u4f7f\u7528 git pull \u547d\u4ee4\u6765\u540c\u6b65\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u4ee3\u7801\u5230\u672c\u5730\u3002\u5c3d\u7ba1\u8fd9\u4e2a\u547d\u4ee4\u975e\u5e38\u7b80\u5355\u6613\u7528\uff0c\u4f46\u6709\u65f6\u5019\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u9519\u8bef\uff0c\u751a\u81f3\u5bfc\u81f4\u9879\u76ee\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u3002\u672c\u6587\u5c06\u5206\u6790 git pull \u5e38\u89c1\u7684\u9519\u8bef\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\u3002 \u4e00\u3001\u9519\u8bef\u4fe1\u606f error: Your local changes to &#8216;file-name&#8217; would be overwritten by merge \u8fd9\u662f\u56e0\u4e3a\u6709\u672c\u5730\u4ee3\u7801\u6ca1\u6709\u63d0\u4ea4\uff0c\u4f1a\u5bfc\u81f4 Git pull \u5408\u5e76\u4ee3\u7801\u65f6\u51fa\u73b0\u51b2\u7a81\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u5148\u5c06\u672c\u5730\u4fee\u6539\u63d0\u4ea4\uff0c\u6216\u8005\u4f7f\u7528 git stash \u547d\u4ee4\u5c06\u4fee\u6539\u7f13\u5b58\u8d77\u6765\uff0c\u518d\u4f7f\u7528 git pull \uff0c\u6700\u540e\u5408\u5e76\u4ee3\u7801\u3002 error: The following untracked working tree files would be overwritten by merge \u8fd9\u4e2a\u9519\u8bef\u662f\u56e0\u4e3a\u4f60\u5728\u672c\u5730\u521b\u5efa\u4e86\u65b0\u6587\u4ef6\u6216\u4fee\u6539\u6587\u4ef6\uff0c\u8fd9\u4e9b\u6587\u4ef6\u6ca1\u6709\u88ab Git \u8ddf\u8e2a\uff0c\u4e5f\u6ca1\u6709\u8fdb\u884c git add \u64cd\u4f5c\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u7528 git stash \u547d\u4ee4\u5c06\u8fd9\u4e9b\u4fee\u6539\u7f13\u5b58\uff0c\u5728\u4f7f\u7528 git pull \u540e\u518d\u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-19150","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=19150"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19150\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}