{"id":19216,"date":"2024-11-19T13:42:11","date_gmt":"2024-11-19T05:42:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19216\/"},"modified":"2024-11-19T13:42:11","modified_gmt":"2024-11-19T05:42:11","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8git%e8%bf%9b%e8%a1%8cpush%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19216\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528Git\u8fdb\u884cpush\u64cd\u4f5c"},"content":{"rendered":"<p>\u5728\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u7248\u672c\u7ba1\u7406\u662f\u4e00\u9879\u91cd\u8981\u7684\u5de5\u4f5c\u3002git\u4f5c\u4e3a\u6700\u5e38\u7528\u7684\u7248\u672c\u7ba1\u7406\u5de5\u5177\u4e4b\u4e00\uff0c\u53ef\u4ee5\u5e2e\u52a9\u56e2\u961f\u534f\u4f5c\u66f4\u52a0\u9ad8\u6548\u3002\u5728git\u4e2d\uff0cpush\u64cd\u4f5c\u5373\u662f\u5c06\u672c\u5730\u4ee3\u7801\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528git\u8fdb\u884cpush\u64cd\u4f5c\u3002<\/p>\n<ol>\n<li>\u5f00\u542fSSH\u8ba4\u8bc1<\/li>\n<\/ol>\n<p>\u82e5\u5df2\u5b8c\u6210\u62f7\u8d1d\u8fdc\u7a0b\u4ed3\u5e93\u64cd\u4f5c\uff0c\u5219\u9700\u8981\u5148\u884c\u5f00\u542fSSH\u8ba4\u8bc1\u3002\u6253\u5f00\u7ec8\u7aef\uff08MacOS\/Linux\uff09\u6216Git Bash\uff08Windows\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>ssh-keygen -t rsa -C \"your_email@example.com\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0c\u201cyour_email@example.com\u201d\u9700\u66ff\u6362\u4e3a\u6ce8\u518cGitHub\/GitLab\u4f7f\u7528\u7684\u90ae\u7bb1\u5730\u5740\u3002\u6309\u4e0b\u56de\u8f66\uff0c\u6b64\u65f6\u5c06\u521b\u5efa\u516c\/\u79c1\u94a5\u5bf9\uff1a<\/p>\n<pre>Generating public\/private rsa key pair.\nEnter file in which to save the key (\/Users\/you\/.ssh\/id_rsa):<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6839\u636e\u63d0\u793a\u4e00\u6b65\u6b65\u5b8c\u6210\u8bbe\u7f6e\uff0c\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u8ba9SSH\u9a8c\u8bc1\u6dfb\u52a0\u5230Agent\u4e2d\uff1a<\/p>\n<pre>eval \"$(ssh-agent -s)\"\nssh-add ~\/.ssh\/id_rsa<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93<\/li>\n<\/ol>\n<p>\u5728\u672c\u5730\u4ee3\u7801\u4ed3\u5e93\u4e0b\u8fd0\u884c\u547d\u4ee4\uff1a<\/p>\n<pre>git remote add origin git@xxxxxx.git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0corigin\u662f\u8fdc\u7a0b\u5e93\u540d\uff0c\u4f9d\u636e\u559c\u597d\u53ef\u81ea\u7531\u66f4\u6539\uff0cgit@xxxxxx.git\u5219\u4e3aSSH\u683c\u5f0f\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\uff0c\u5e94\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u5730\u5740\u3002<\/p>\n<ol>\n<li>\u68c0\u67e5\u672c\u5730\u4ed3\u5e93<\/li>\n<\/ol>\n<p>\u5728\u540c\u6b65\u5230\u8fdc\u7a0b\u4ed3\u5e93\u524d\uff0c\u9700\u786e\u4fdd\u672c\u5730\u4ee3\u7801\u4ed3\u5e93\u5904\u4e8e\u6b63\u786e\u7684\u5206\u652f\u3002\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u6240\u5904\u5206\u652f\uff1a<\/p>\n<pre>git branch<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8be5\u547d\u4ee4\u8f93\u51fa\u4e2d\uff0c\u524d\u9762\u5e26\u6709*\u7684\u5206\u652f\u5373\u4e3a\u5f53\u524d\u6240\u5728\u5206\u652f\u3002<\/p>\n<ol>\n<li>\u63d0\u4ea4\u4ee3\u7801<\/li>\n<\/ol>\n<p>\u5b8c\u6210\u4ee3\u7801\u4fee\u6539\u540e\uff0c\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5c06\u66f4\u6539\u5185\u5bb9\u6682\u5b58\u81f3\u672c\u5730\u4ed3\u5e93\uff1a<\/p>\n<pre>git add .<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d.\u8868\u793a\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u3002\u82e5\u8981\u53ea\u63d0\u4ea4\u67d0\u4e9b\u6587\u4ef6\u7684\u66f4\u6539\uff0c\u5219\u53ef\u5c06.\u66ff\u6362\u6210\u6587\u4ef6\u540d\u3002<\/p>\n<p>\u63d0\u4ea4\u66f4\u6539\u5185\u5bb9\uff1a<\/p>\n<pre>git commit -m \"commit message\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0ccommit message\u5e94\u586b\u5199\u6709\u610f\u4e49\u7684\u8bc4\u8bba\uff0c\u4ee5\u65b9\u4fbf\u540e\u7eed\u7ba1\u7406\u3002\u4f8b\u5982\uff0c\u201c\u4fee\u6539\u4e86XX\u529f\u80fd\u201d\u7b49\u3002<\/p>\n<ol>\n<li>\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/li>\n<\/ol>\n<p>\u7531\u4e8e\u5f00\u542f\u4e86SSH\u8ba4\u8bc1\uff0c\u6545\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5c06\u672c\u5730\u4ee3\u7801\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<pre>git push origin branch_name<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0cbranch_name\u5e94\u586b\u5199\u9700\u8981push\u7684\u5206\u652f\u540d\uff0c\u4e00\u822c\u4e3amaster\u3002<\/p>\n<p>\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u4ee3\u7801\u5373\u88ab\u63d0\u4ea4\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<ol>\n<li>\u9047\u5230\u63a8\u9001\u5931\u8d25<\/li>\n<\/ol>\n<p>\u5982\u679c\u63a8\u9001\u8fc7\u7a0b\u4e2d\u9047\u5230\u5931\u8d25\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u5148pull\u8fdc\u7a0b\u4ed3\u5e93\u7684\u6700\u65b0\u7248\u672c\uff0c\u518d\u8fdb\u884cpush\u64cd\u4f5c\uff1a<\/p>\n<pre>git pull origin branch_name<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u82e5\u4fee\u6539\u6709\u51b2\u7a81\uff0c\u4f1a\u63d0\u793a\u9700\u8981\u624b\u52a8\u89e3\u51b3\u51b2\u7a81\u3002\u624b\u52a8\u89e3\u51b3\u540e\uff0c\u518d\u6b21\u63d0\u4ea4\u5373\u53ef\u3002<\/p>\n<p>\u4ee5\u4e0a\u5373\u4e3aGit\u8fdb\u884cpush\u64cd\u4f5c\u7684\u8be6\u7ec6\u6d41\u7a0b\uff0c\u5e0c\u671b\u8bfb\u8005\u4eec\u80fd\u591f\u638c\u63e1\u5e76\u719f\u7ec3\u5e94\u7528\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528Git\u8fdb\u884cpush\u64cd\u4f5c\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\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u7248\u672c\u7ba1\u7406\u662f\u4e00\u9879\u91cd\u8981\u7684\u5de5\u4f5c\u3002git\u4f5c\u4e3a\u6700\u5e38\u7528\u7684\u7248\u672c\u7ba1\u7406\u5de5\u5177\u4e4b\u4e00\uff0c\u53ef\u4ee5\u5e2e\u52a9\u56e2\u961f\u534f\u4f5c\u66f4\u52a0\u9ad8\u6548\u3002\u5728git\u4e2d\uff0cpush\u64cd\u4f5c\u5373\u662f\u5c06\u672c\u5730\u4ee3\u7801\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528git\u8fdb\u884cpush\u64cd\u4f5c\u3002 \u5f00\u542fSSH\u8ba4\u8bc1 \u82e5\u5df2\u5b8c\u6210\u62f7\u8d1d\u8fdc\u7a0b\u4ed3\u5e93\u64cd\u4f5c\uff0c\u5219\u9700\u8981\u5148\u884c\u5f00\u542fSSH\u8ba4\u8bc1\u3002\u6253\u5f00\u7ec8\u7aef\uff08MacOS\/Linux\uff09\u6216Git Bash\uff08Windows\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a ssh-keygen -t rsa -C &#8220;your_email@example.com&#8221; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c\u201cyour_email@example.com\u201d\u9700\u66ff\u6362\u4e3a\u6ce8\u518cGitHub\/GitLab\u4f7f\u7528\u7684\u90ae\u7bb1\u5730\u5740\u3002\u6309\u4e0b\u56de\u8f66\uff0c\u6b64\u65f6\u5c06\u521b\u5efa\u516c\/\u79c1\u94a5\u5bf9\uff1a Generating public\/private rsa key pair. Enter file in which to save the key (\/Users\/you\/.ssh\/id_rsa): \u767b\u5f55\u540e\u590d\u5236 \u6839\u636e\u63d0\u793a\u4e00\u6b65\u6b65\u5b8c\u6210\u8bbe\u7f6e\uff0c\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u8ba9SSH\u9a8c\u8bc1\u6dfb\u52a0\u5230Agent\u4e2d\uff1a eval &#8220;$(ssh-agent -s)&#8221; ssh-add ~\/.ssh\/id_rsa \u767b\u5f55\u540e\u590d\u5236 \u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93 \u5728\u672c\u5730\u4ee3\u7801\u4ed3\u5e93\u4e0b\u8fd0\u884c\u547d\u4ee4\uff1a git remote add origin git@xxxxxx.git \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0corigin\u662f\u8fdc\u7a0b\u5e93\u540d\uff0c\u4f9d\u636e\u559c\u597d\u53ef\u81ea\u7531\u66f4\u6539\uff0cgit@xxxxxx.git\u5219\u4e3aSSH\u683c\u5f0f\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\uff0c\u5e94\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u5730\u5740\u3002 \u68c0\u67e5\u672c\u5730\u4ed3\u5e93 \u5728\u540c\u6b65\u5230\u8fdc\u7a0b\u4ed3\u5e93\u524d\uff0c\u9700\u786e\u4fdd\u672c\u5730\u4ee3\u7801\u4ed3\u5e93\u5904\u4e8e\u6b63\u786e\u7684\u5206\u652f\u3002\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u6240\u5904\u5206\u652f\uff1a git branch \u767b\u5f55\u540e\u590d\u5236 \u8be5\u547d\u4ee4\u8f93\u51fa\u4e2d\uff0c\u524d\u9762\u5e26\u6709*\u7684\u5206\u652f\u5373\u4e3a\u5f53\u524d\u6240\u5728\u5206\u652f\u3002 \u63d0\u4ea4\u4ee3\u7801 \u5b8c\u6210\u4ee3\u7801\u4fee\u6539\u540e\uff0c\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5c06\u66f4\u6539\u5185\u5bb9\u6682\u5b58\u81f3\u672c\u5730\u4ed3\u5e93\uff1a git add . \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d.\u8868\u793a\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u3002\u82e5\u8981\u53ea\u63d0\u4ea4\u67d0\u4e9b\u6587\u4ef6\u7684\u66f4\u6539\uff0c\u5219\u53ef\u5c06.\u66ff\u6362\u6210\u6587\u4ef6\u540d\u3002 [&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-19216","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19216","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=19216"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19216\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}