{"id":21576,"date":"2024-11-19T12:05:25","date_gmt":"2024-11-19T04:05:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21576\/"},"modified":"2024-11-19T12:05:25","modified_gmt":"2024-11-19T04:05:25","slug":"git%e6%80%8e%e4%b9%88push%e5%88%b0github","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21576\/","title":{"rendered":"git\u600e\u4e48push\u5230github"},"content":{"rendered":"<blockquote><p>\n  \u8981\u5c06\u4ee3\u7801\u63a8\u9001\u81f3 github\uff0c\u8bf7\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u521d\u59cb\u5316 git \u4ed3\u5e93\u5e76\u521b\u5efa github \u5b58\u50a8\u5e93\u3002\u5c06\u672c\u5730\u4ed3\u5e93\u4e0e github \u5b58\u50a8\u5e93\u5173\u8054\u3002\u5c06\u66f4\u6539\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u5e76\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93\u3002\u5c06\u66f4\u6539\u63a8\u9001\u81f3 github \u5b58\u50a8\u5e93\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100343345879.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48push\u5230github\u63d2\u56fe\" alt=\"git\u600e\u4e48push\u5230github\u63d2\u56fe\" \/><\/p>\n<h2>\u5982\u4f55\u5c06\u4ee3\u7801\u63a8\u9001\uff08push\uff09\u5230 GitHub<\/h2>\n<h3>\u6b65\u9aa4 1\uff1a\u521d\u59cb\u5316 Git \u4ed3\u5e93<\/h3>\n<ul>\n<li>\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u5bfc\u822a\u5230\u8981\u63a8\u9001\u4ee3\u7801\u7684\u76ee\u5f55\u3002<\/li>\n<li>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u521d\u59cb\u5316 Git \u4ed3\u5e93\uff1a<\/p>\n<pre>git init<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<h3>\u6b65\u9aa4 2\uff1a\u521b\u5efa GitHub \u5b58\u50a8\u5e93<\/h3>\n<ul>\n<li>\u5728 GitHub \u7f51\u7ad9\u4e0a\uff0c\u5355\u51fb\u53f3\u4e0a\u89d2\u7684\u201c+\u201d\u6309\u94ae\uff0c\u7136\u540e\u9009\u62e9\u201cNew repository\u201d\u3002<\/li>\n<li>\u4e3a\u5b58\u50a8\u5e93\u8f93\u5165\u540d\u79f0\u3001\u63cf\u8ff0\uff08\u53ef\u9009\uff09\u5e76\u5355\u51fb\u201cCreate repository\u201d\u3002<\/li>\n<\/ul>\n<h3>\u6b65\u9aa4 3\uff1a\u5c06\u4e0e GitHub \u5b58\u50a8\u5e93\u76f8\u5173\u8054<\/h3>\n<ul>\n<li>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u672c\u5730\u4ed3\u5e93\u4e0e GitHub \u5b58\u50a8\u5e93\u5173\u8054\uff1a<\/p>\n<pre>git remote add origin https:\/\/github.com\/&lt;user&gt;\/&lt;repository&gt;.git<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u66ff\u6362 \u4e3a\u60a8\u7684 GitHub \u7528\u6237\u540d\uff0c \u4e3a\u5b58\u50a8\u5e93\u7684\u540d\u79f0\u3002 <\/li>\n<\/ul>\n<h3>\u6b65\u9aa4 4\uff1a\u6dfb\u52a0\u548c\u63d0\u4ea4\u66f4\u6539<\/h3>\n<ul>\n<li>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u60a8\u8981\u63a8\u9001\u7684\u66f4\u6539\u6dfb\u52a0\u5230 Git \u6682\u5b58\u533a\uff1a<\/p>\n<pre>git add .<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6682\u5b58\u66f4\u6539\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93\uff1a<\/p>\n<pre>git commit -m \"Commit message\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u5c06\u201cCommit message\u201d\u66ff\u6362\u4e3a\u60a8\u63d0\u4ea4\u7684\u7b80\u77ed\u63cf\u8ff0\u3002<\/li>\n<\/ul>\n<h3>\u6b65\u9aa4 5\uff1a\u63a8\u9001\u66f4\u6539<\/h3>\n<ul>\n<li>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u66f4\u6539\u63a8\u9001\uff08push\uff09\u5230 GitHub \u5b58\u50a8\u5e93\uff1a<\/p>\n<pre>git push origin main<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>main \u662f GitHub \u4e0a\u9ed8\u8ba4\u5206\u652f\u7684\u540d\u79f0\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u5176\u4ed6\u5206\u652f\uff0c\u8bf7\u76f8\u5e94\u5730\u66ff\u6362\u5b83\u3002<\/li>\n<\/ul>\n<h3>\u6545\u969c\u6392\u9664<\/h3>\n<ul>\n<li> <strong>Permission denied (\u62d2\u7edd\u6743\u9650)<\/strong>\uff1a\u786e\u4fdd\u60a8\u5df2\u5c06 GitHub \u5b58\u50a8\u5e93\u514b\u9686\u5230\u672c\u5730\u673a\u5668\uff0c\u5e76\u4e14\u62e5\u6709\u9002\u5f53\u7684\u63a8\u9001\u6743\u9650\u3002<\/li>\n<li> <strong>Invalid remote repository (\u65e0\u6548\u7684\u8fdc\u7a0b\u4ed3\u5e93)<\/strong>\uff1a\u786e\u4fdd\u60a8\u8f93\u5165\u4e86\u6b63\u786e\u7684 GitHub \u5b58\u50a8\u5e93 URL\u3002<\/li>\n<li>\n<p><strong>Up to date (\u5df2\u662f\u6700\u65b0)<\/strong>\uff1a\u5982\u679c\u60a8\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u65b0\u66f4\u6539\uff0c\u60a8\u5c06\u770b\u5230\u6b64\u6d88\u606f\u3002\u53ea\u9700\u62c9\u53d6\uff08pull\uff09\u8fdc\u7a0b\u66f4\u6539\u5373\u53ef\uff1a<\/p>\n<pre>git pull origin main<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48push\u5230github\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\u5c06\u4ee3\u7801\u63a8\u9001\u81f3 github\uff0c\u8bf7\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u521d\u59cb\u5316 git \u4ed3\u5e93\u5e76\u521b\u5efa github \u5b58\u50a8\u5e93\u3002\u5c06\u672c\u5730\u4ed3\u5e93\u4e0e github \u5b58\u50a8\u5e93\u5173\u8054\u3002\u5c06\u66f4\u6539\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u5e76\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93\u3002\u5c06\u66f4\u6539\u63a8\u9001\u81f3 github \u5b58\u50a8\u5e93\u3002 \u5982\u4f55\u5c06\u4ee3\u7801\u63a8\u9001\uff08push\uff09\u5230 GitHub \u6b65\u9aa4 1\uff1a\u521d\u59cb\u5316 Git \u4ed3\u5e93 \u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u5bfc\u822a\u5230\u8981\u63a8\u9001\u4ee3\u7801\u7684\u76ee\u5f55\u3002 \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u521d\u59cb\u5316 Git \u4ed3\u5e93\uff1a git init \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4 2\uff1a\u521b\u5efa GitHub \u5b58\u50a8\u5e93 \u5728 GitHub \u7f51\u7ad9\u4e0a\uff0c\u5355\u51fb\u53f3\u4e0a\u89d2\u7684\u201c+\u201d\u6309\u94ae\uff0c\u7136\u540e\u9009\u62e9\u201cNew repository\u201d\u3002 \u4e3a\u5b58\u50a8\u5e93\u8f93\u5165\u540d\u79f0\u3001\u63cf\u8ff0\uff08\u53ef\u9009\uff09\u5e76\u5355\u51fb\u201cCreate repository\u201d\u3002 \u6b65\u9aa4 3\uff1a\u5c06\u4e0e GitHub \u5b58\u50a8\u5e93\u76f8\u5173\u8054 \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u672c\u5730\u4ed3\u5e93\u4e0e GitHub \u5b58\u50a8\u5e93\u5173\u8054\uff1a git remote add origin https:\/\/github.com\/&lt;user&gt;\/&lt;repository&gt;.git \u767b\u5f55\u540e\u590d\u5236 \u66ff\u6362 \u4e3a\u60a8\u7684 GitHub \u7528\u6237\u540d\uff0c \u4e3a\u5b58\u50a8\u5e93\u7684\u540d\u79f0\u3002 \u6b65\u9aa4 4\uff1a\u6dfb\u52a0\u548c\u63d0\u4ea4\u66f4\u6539 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u60a8\u8981\u63a8\u9001\u7684\u66f4\u6539\u6dfb\u52a0\u5230 Git [&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-21576","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21576","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=21576"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21576\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}