{"id":21558,"date":"2024-11-19T16:57:06","date_gmt":"2024-11-19T08:57:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21558\/"},"modified":"2024-11-19T16:57:06","modified_gmt":"2024-11-19T08:57:06","slug":"git%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3%e5%86%b2%e7%aa%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21558\/","title":{"rendered":"git\u600e\u4e48\u89e3\u51b3\u51b2\u7a81"},"content":{"rendered":"<blockquote><p>\n  \u8981\u89e3\u51b3 git \u51b2\u7a81\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u68c0\u6d4b\u51b2\u7a81\uff1b\u786e\u5b9a\u51b2\u7a81\u6765\u6e90\u5e76\u624b\u52a8\u89e3\u51b3\uff1b\u4fdd\u6301\u4e00\u4e2a\u7248\u672c\u3001\u5408\u5e76\u4e24\u4e2a\u7248\u672c\u6216\u56de\u9000\u4e00\u4e2a\u7248\u672c\uff1b\u63d0\u4ea4\u5408\u5e76\u7684\u66f4\u6539\uff1b\u63a8\u9001\u66f4\u6539\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100010818187.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48\u89e3\u51b3\u51b2\u7a81\u63d2\u56fe\" alt=\"git\u600e\u4e48\u89e3\u51b3\u51b2\u7a81\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u89e3\u51b3 Git \u51b2\u7a81<\/strong><\/p>\n<p>\u5f53\u4e24\u4e2a\u6216\u591a\u4e2a\u5f00\u53d1\u4eba\u5458\u540c\u65f6\u7f16\u8f91\u540c\u4e00\u6587\u4ef6\u7684\u540c\u4e00\u90e8\u5206\u65f6\uff0c\u5c31\u4f1a\u51fa\u73b0 Git \u51b2\u7a81\u3002\u89e3\u51b3\u8fd9\u4e9b\u51b2\u7a81\u5bf9\u4e8e\u4fdd\u6301\u4ee3\u7801\u5e93\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p><strong>\u5982\u4f55\u68c0\u6d4b\u51b2\u7a81<\/strong><\/p>\n<p>\u5728 Git \u4e2d\u6267\u884c  pull \u6216 git fetch \u65f6\uff0c\u7cfb\u7edf\u5c06\u68c0\u67e5\u662f\u5426\u5b58\u5728\u51b2\u7a81\u3002\u5982\u679c\u68c0\u6d4b\u5230\u51b2\u7a81\uff0c\u547d\u4ee4\u5c06\u4e2d\u6b62\uff0c\u5e76\u663e\u793a\u4e00\u6761\u51b2\u7a81\u6d88\u606f\u3002<\/p>\n<p><strong>\u5982\u4f55\u89e3\u51b3\u51b2\u7a81<\/strong><\/p>\n<p><strong>1. \u786e\u5b9a\u51b2\u7a81\u7684\u6765\u6e90<\/strong><\/p>\n<p>\u67e5\u770b\u51b2\u7a81\u6d88\u606f\uff0c\u4e86\u89e3\u51b2\u7a81\u6587\u4ef6\u7684\u540d\u79f0\u548c\u884c\u53f7\u3002\u8fd9\u5c06\u5e2e\u52a9\u4f60\u4e86\u89e3\u54ea\u4e9b\u5f00\u53d1\u4eba\u5458\u7f16\u8f91\u4e86\u6709\u51b2\u7a81\u7684\u884c\u3002<\/p>\n<p><strong>2. \u624b\u52a8\u89e3\u51b3\u51b2\u7a81<\/strong><\/p>\n<p>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u6709\u51b2\u7a81\u7684\u6587\u4ef6\u3002\u51b2\u7a81\u7684\u533a\u57df\u5c06\u4ee5 &gt;&gt;&gt;&gt;&gt;&gt; \u5206\u9694\u7b26\u7a81\u51fa\u663e\u793a\u3002<\/p>\n<ul>\n<li> <strong>\u4fdd\u6301\u4e00\u4e2a\u7248\u672c\uff1a<\/strong>\u5982\u679c\u4e00\u4e2a\u7248\u672c\u7684\u66f4\u6539\u662f\u5fc5\u9700\u7684\uff0c\u800c\u53e6\u4e00\u4e2a\u7248\u672c\u662f\u591a\u4f59\u7684\uff0c\u8bf7\u4fdd\u7559\u5fc5\u9700\u7684\u7248\u672c\u3002<\/li>\n<li> <strong>\u5408\u5e76\u4e24\u4e2a\u7248\u672c\uff1a<\/strong>\u5982\u679c\u4e24\u4e2a\u7248\u672c\u90fd\u5305\u542b\u5fc5\u8981\u7684\u66f4\u6539\uff0c\u8bf7\u5c1d\u8bd5\u5408\u5e76\u5b83\u4eec\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7248\u672c\u3002<\/li>\n<li> <strong>\u56de\u9000\u4e00\u4e2a\u7248\u672c\uff1a<\/strong>\u5982\u679c\u51b2\u7a81\u65e0\u6cd5\u89e3\u51b3\uff0c\u8bf7\u901a\u8fc7\u6267\u884c git checkout &#8211;ours file.txt \u6216 git checkout &#8211;theirs file.txt \u6765\u6062\u590d\u5230\u5176\u4e2d\u4e00\u4e2a\u7248\u672c\u3002<\/li>\n<\/ul>\n<p><strong>3. \u63d0\u4ea4\u5408\u5e76\u7684\u66f4\u6539<\/strong><\/p>\n<p>\u89e3\u51b3\u6240\u6709\u51b2\u7a81\u540e\uff0c\u63d0\u4ea4\u5408\u5e76\u7684\u66f4\u6539\u3002\u6267\u884c git add file.txt \u5c06\u66f4\u6539\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u57df\uff0c\u7136\u540e\u6267\u884c git commit -m &#8220;Resolve conflicts&#8221; \u63d0\u4ea4\u66f4\u6539\u3002<\/p>\n<p><strong>4. \u63a8\u9001\u66f4\u6539<\/strong><\/p>\n<p>\u6700\u540e\uff0c\u6267\u884c git push \u5c06\u5408\u5e76\u7684\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<p><strong>\u907f\u514d\u51b2\u7a81\u7684\u63d0\u793a<\/strong><\/p>\n<ul>\n<li> <strong>\u7ecf\u5e38\u63a8\u9001\u548c\u62c9\u53d6\uff1a<\/strong>\u8fd9\u6709\u52a9\u4e8e\u786e\u4fdd\u4f60\u7684\u672c\u5730\u526f\u672c\u662f\u6700\u65b0\u7684\uff0c\u51cf\u5c11\u51b2\u7a81\u7684\u673a\u4f1a\u3002<\/li>\n<li> <strong>\u4f7f\u7528\u5206\u652f\uff1a<\/strong>\u5728\u8fdb\u884c\u91cd\u5927\u66f4\u6539\u4e4b\u524d\uff0c\u8bf7\u4f7f\u7528\u5206\u652f\u4ee5\u907f\u514d\u4e0e\u5176\u4ed6\u5f00\u53d1\u4eba\u5458\u53d1\u751f\u51b2\u7a81\u3002<\/li>\n<li> <strong>\u4f7f\u7528\u5408\u5e76\u5de5\u5177\uff1a<\/strong>\u5982\u679c\u624b\u52a8\u89e3\u51b3\u51b2\u7a81\u6709\u56f0\u96be\uff0c\u53ef\u4ee5\u4f7f\u7528 Git \u5ba2\u6237\u7aef\u6216\u7b2c\u4e09\u65b9\u5408\u5e76\u5de5\u5177\u6765\u5e2e\u52a9\u4f60\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u89e3\u51b3\u51b2\u7a81\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>\u8981\u89e3\u51b3 git \u51b2\u7a81\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u68c0\u6d4b\u51b2\u7a81\uff1b\u786e\u5b9a\u51b2\u7a81\u6765\u6e90\u5e76\u624b\u52a8\u89e3\u51b3\uff1b\u4fdd\u6301\u4e00\u4e2a\u7248\u672c\u3001\u5408\u5e76\u4e24\u4e2a\u7248\u672c\u6216\u56de\u9000\u4e00\u4e2a\u7248\u672c\uff1b\u63d0\u4ea4\u5408\u5e76\u7684\u66f4\u6539\uff1b\u63a8\u9001\u66f4\u6539\u3002 \u5982\u4f55\u89e3\u51b3 Git \u51b2\u7a81 \u5f53\u4e24\u4e2a\u6216\u591a\u4e2a\u5f00\u53d1\u4eba\u5458\u540c\u65f6\u7f16\u8f91\u540c\u4e00\u6587\u4ef6\u7684\u540c\u4e00\u90e8\u5206\u65f6\uff0c\u5c31\u4f1a\u51fa\u73b0 Git \u51b2\u7a81\u3002\u89e3\u51b3\u8fd9\u4e9b\u51b2\u7a81\u5bf9\u4e8e\u4fdd\u6301\u4ee3\u7801\u5e93\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\u81f3\u5173\u91cd\u8981\u3002 \u5982\u4f55\u68c0\u6d4b\u51b2\u7a81 \u5728 Git \u4e2d\u6267\u884c pull \u6216 git fetch \u65f6\uff0c\u7cfb\u7edf\u5c06\u68c0\u67e5\u662f\u5426\u5b58\u5728\u51b2\u7a81\u3002\u5982\u679c\u68c0\u6d4b\u5230\u51b2\u7a81\uff0c\u547d\u4ee4\u5c06\u4e2d\u6b62\uff0c\u5e76\u663e\u793a\u4e00\u6761\u51b2\u7a81\u6d88\u606f\u3002 \u5982\u4f55\u89e3\u51b3\u51b2\u7a81 1. \u786e\u5b9a\u51b2\u7a81\u7684\u6765\u6e90 \u67e5\u770b\u51b2\u7a81\u6d88\u606f\uff0c\u4e86\u89e3\u51b2\u7a81\u6587\u4ef6\u7684\u540d\u79f0\u548c\u884c\u53f7\u3002\u8fd9\u5c06\u5e2e\u52a9\u4f60\u4e86\u89e3\u54ea\u4e9b\u5f00\u53d1\u4eba\u5458\u7f16\u8f91\u4e86\u6709\u51b2\u7a81\u7684\u884c\u3002 2. \u624b\u52a8\u89e3\u51b3\u51b2\u7a81 \u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u6709\u51b2\u7a81\u7684\u6587\u4ef6\u3002\u51b2\u7a81\u7684\u533a\u57df\u5c06\u4ee5 &gt;&gt;&gt;&gt;&gt;&gt; \u5206\u9694\u7b26\u7a81\u51fa\u663e\u793a\u3002 \u4fdd\u6301\u4e00\u4e2a\u7248\u672c\uff1a\u5982\u679c\u4e00\u4e2a\u7248\u672c\u7684\u66f4\u6539\u662f\u5fc5\u9700\u7684\uff0c\u800c\u53e6\u4e00\u4e2a\u7248\u672c\u662f\u591a\u4f59\u7684\uff0c\u8bf7\u4fdd\u7559\u5fc5\u9700\u7684\u7248\u672c\u3002 \u5408\u5e76\u4e24\u4e2a\u7248\u672c\uff1a\u5982\u679c\u4e24\u4e2a\u7248\u672c\u90fd\u5305\u542b\u5fc5\u8981\u7684\u66f4\u6539\uff0c\u8bf7\u5c1d\u8bd5\u5408\u5e76\u5b83\u4eec\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7248\u672c\u3002 \u56de\u9000\u4e00\u4e2a\u7248\u672c\uff1a\u5982\u679c\u51b2\u7a81\u65e0\u6cd5\u89e3\u51b3\uff0c\u8bf7\u901a\u8fc7\u6267\u884c git checkout &#8211;ours file.txt \u6216 git checkout &#8211;theirs file.txt \u6765\u6062\u590d\u5230\u5176\u4e2d\u4e00\u4e2a\u7248\u672c\u3002 3. \u63d0\u4ea4\u5408\u5e76\u7684\u66f4\u6539 \u89e3\u51b3\u6240\u6709\u51b2\u7a81\u540e\uff0c\u63d0\u4ea4\u5408\u5e76\u7684\u66f4\u6539\u3002\u6267\u884c git add file.txt \u5c06\u66f4\u6539\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u57df\uff0c\u7136\u540e\u6267\u884c git commit -m &#8220;Resolve conflicts&#8221; \u63d0\u4ea4\u66f4\u6539\u3002 4. \u63a8\u9001\u66f4\u6539 [&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-21558","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21558","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=21558"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21558\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}