{"id":39794,"date":"2024-11-26T13:53:19","date_gmt":"2024-11-26T05:53:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39794\/"},"modified":"2024-11-26T13:53:19","modified_gmt":"2024-11-26T05:53:19","slug":"%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86-git%e4%bd%bf%e7%94%a8%e4%b8%adpush%e6%8a%a5%e9%94%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39794\/","title":{"rendered":"\u5982\u4f55\u5904\u7406 git\u4f7f\u7528\u4e2dpush\u62a5\u9519"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173054757393286.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5904\u7406 git\u4f7f\u7528\u4e2dpush\u62a5\u9519\u63d2\u56fe\" alt=\"\u5982\u4f55\u5904\u7406 git\u4f7f\u7528\u4e2dpush\u62a5\u9519\u63d2\u56fe\" \/><\/p>\n<p>\u95f4\u9694\u4e86\u4e00\u6bb5\u65f6\u95f4\u672a\u5f80lab\u4e0apush\u6587\u4ef6\uff0c\u8fd1\u671f\u4f7f\u7528\u65f6\uff0c\u53d1\u73b0push\u65f6\u62a5\u9519\uff0c\u8fd9\u91cc\u8bb0\u5f55\u4e0b\u89e3\u51b3\u5904\u7406\u7684\u65b9\u6cd5\u3002<\/p>\n<p><span style=\"color: #1e1e1e;letter-spacing: 2px;border-left: #FF3030 3px solid;border-right: #FF3030 3px solid;padding-left: 8px;padding-right: 8px;font-size: 12pt\"><strong>\u9519\u8bef\u4e00\uff1a<\/strong><\/span> <\/p>\n<pre>[root@361way shell]# git push\nwarning: push.default is unset; its implicit value is changing in\nGit 2.0 from 'matching' to 'simple'. To squelch this message\nand maintain the current behavior after the default changes, use:\ngit config --global push.default matching\nTo squelch this message and adopt the new behavior now, use:\ngit config --global push.default simple\nSee 'git help config' and search for 'push.default' for further information.\n(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n'current' instead of 'simple' if you sometimes use older versions of Git)\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u653e&#8221;\u72d7&#8221;\u67e5\u8be2\u540e\uff0c\u5f97\u77e5\u2018matching\u2019 \u53c2\u6570\u662f Git 1.x \u7684\u9ed8\u8ba4\u884c\u4e3a\uff0c\u5176\u610f\u662f\u5982\u679c\u4f60\u6267\u884c git push \u4f46\u6ca1\u6709\u6307\u5b9a\u5206\u652f\uff0c\u5b83\u5c06 push \u6240\u6709\u4f60\u672c\u5730\u7684\u5206\u652f\u5230\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u5bf9\u5e94\u5339\u914d\u7684\u5206\u652f\u3002\u800c Git 2.x \u9ed8\u8ba4\u7684\u662f simple\uff0c\u610f\u5473\u7740\u6267\u884c git push \u6ca1\u6709\u6307\u5b9a\u5206\u652f\u65f6\uff0c\u53ea\u6709\u5f53\u524d\u5206\u652f\u4f1a\u88ab push \u5230\u4f60\u4f7f\u7528 git pull \u83b7\u53d6\u7684\u4ee3\u7801\u3002\u952e\u5165\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>[root@361way shell]# git config --global push.default matching\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236<br \/>\n<span style=\"color: #1e1e1e;letter-spacing: 2px;border-left: #FF3030 3px solid;border-right: #FF3030 3px solid;padding-left: 8px;padding-right: 8px;font-size: 12pt\"><strong>\u9519\u8bef\u4e8c\uff1a<\/strong><\/span> <\/p>\n<pre>[root@361way shell]# git push -u origin master\nTo https:\/\/361way:mypassword@github.com\/361way\/shell.git\n! [rejected] master -&gt; master (fetch first)\nerror: failed to push some refs to 'https:\/\/361way:mypassword@github.com\/361way\/shell.git'\nhint: Updates were rejected because the remote contains work that you do\nhint: not have locally. This is usually caused by another repository pushing\nhint: to the same ref. You may want to first merge the remote changes (e.g.,\nhint: 'git pull') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u518d\u6b21push\uff0c\u53d1\u73b0\u53c8\u6709\u62a5\u9519\uff0c\u6839\u636e\u62a5\u9519\u5185\u5bb9\uff0c\u5927\u81f4\u4e86\u89e3\u7684\u60c5\u51b5\u662f\uff0c\u672c\u5730\u548c\u8fdc\u7aef\u7684\u5185\u5bb9\u53ef\u80fd\u4e0d\u4e00\u81f4\uff0c\u5efa\u8baegit pull \u4e00\u4efd\uff0c\u518dpush\u5230romte \u3002\u7531\u4e8e\u5e73\u65f6\u6709\u4e9b\u4fee\u6539\u4f1a\u5728\u963f\u91cc\u4e91\u670d\u52a1\u5668\u4e0a\u4fee\u6539\u8fc7\u7684\u61d2\u5f97push\u5230\u8fdc\u7aef\u540c\u6b65\uff0c\u6240\u4ee5\u672c\u5730\u548c\u8fdc\u7aef\u7684\u4e0d\u4e00\u81f4\u4e5f\u662f\u6709\u53ef\u80fd\u7684\u3002\u5373\u7136\u4e0d\u4e00\u81f4\uff0c\u4ee5\u963f\u91cc\u4e91\u4e0a\u4fdd\u5b58\u7684\u4e3a\u51c6\u5427\uff0c\u5f3a\u5236\u540c\u6b65\u4e0b\u3002<\/p>\n<pre>[root@361way shell]# git push -u origin master --force\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5f3a\u5236\u540c\u6b65\uff0c\u53d1\u73b0\u53ef\u4ee5\u6b63\u5e38\u540c\u6b65\u5185\u5bb9\u5230github\u4e0a\uff0c\u800c\u4e14\u540e\u9762\u518d\u52a0\u6587\u4ef6\u8fdb\u884c\u540c\u6b65\uff0c\u53d1\u73b0\u4e5f\u672a\u51fa\u73b0\u62a5\u9519\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5904\u7406 \u4f7f\u7528\u4e2dpush\u62a5\u9519\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>\u95f4\u9694\u4e86\u4e00\u6bb5\u65f6\u95f4\u672a\u5f80lab\u4e0apush\u6587\u4ef6\uff0c\u8fd1\u671f\u4f7f\u7528\u65f6\uff0c\u53d1\u73b0push\u65f6\u62a5\u9519\uff0c\u8fd9\u91cc\u8bb0\u5f55\u4e0b\u89e3\u51b3\u5904\u7406\u7684\u65b9\u6cd5\u3002 \u9519\u8bef\u4e00\uff1a [root@361way shell]# git push warning: push.default is unset; its implicit value is changing in Git 2.0 from &#8216;matching&#8217; to &#8216;simple&#8217;. To squelch this message and maintain the current behavior after the default changes, use: git config &#8211;global push.default matching To squelch this message and adopt the new behavior now, use: git config &#8211;global [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-39794","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39794","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=39794"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39794\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}