{"id":56,"date":"2022-07-14T21:37:44","date_gmt":"2022-07-14T13:37:44","guid":{"rendered":"https:\/\/cubeline.xyz\/?p=56"},"modified":"2026-04-17T13:57:30","modified_gmt":"2026-04-17T05:57:30","slug":"git%e4%bd%bf%e7%94%a8%e7%ae%80%e8%a6%81","status":"publish","type":"post","link":"https:\/\/turbostudio.xyz\/?p=56","title":{"rendered":"GIT\u4f7f\u7528\u7b80\u8981"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u68c0\u67e5git\u7528\u6237\u540d\u548c\u90ae\u7bb1<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$git config &#8211;global &#8211;list<\/p>\n<\/blockquote>\n\n\n\n<p>\u9ed8\u8ba4\u4f1a\u663e\u793a\u5168\u5c40\u53c2\u6570\uff0c\u5982\u672a\u663e\u793a\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u914d\u7f6e<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$git config &#8211;global user.name &#8220;\u4f60\u7684\u7528\u6237\u540d&#8221;<br>$git config &#8211;global user.email &#8220;\u4f60\u7684\u90ae\u7bb1&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u4f7f\u7528ssh-keygen\u751f\u6210\u5bc6\u94a5<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ssh-keygen -t rsa -C &#8220;your email&#8221; <\/p>\n<\/blockquote>\n\n\n\n<p>\u6309\u7167\u63d0\u793a\u5b8c\u6210\u8bbe\u7f6e\uff0c\u6ce8\u610f\u6b64\u65f6\u9700\u8981\u6ce8\u610f\u786e\u8ba4\u5bc6\u94a5\u7684\u4fdd\u5b58\u8def\u5f84\u3001\u5bc6\u7801\u3001\u540d\u79f0\u7b49\u4fe1\u606f\uff0c\u82e5\u540d\u79f0\u680f\u672a\u8f93\u5165\uff0c\u5219\u9ed8\u8ba4\u751f\u6210id_rsa\u548cid_rsa.pub\u4e24\u4e2a\u6587\u4ef6\u3002\u5176\u4e2did_rsa\u5bf9\u5e94\u79c1\u94a5\u6587\u4ef6\uff0c\u5e94\u59a5\u5584\u4fdd\u7ba1\uff0cid_rsa.pub\u4e3a\u516c\u94a5\u6587\u4ef6\uff0c\u5185\u5bb9\u9700\u4e0a\u4f20\u81f3GitHub\u4ed3\u5e93\u7684\u914d\u7f6e\u680f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u6dfb\u52a0\u516c\u94a5\u81f3\u8fdc\u7a0b\u4ed3\u5e93<\/h2>\n\n\n\n<p>\u6253\u5f00GitHub\u7528\u6237settings\u9875\u9762\uff0c\u9009\u62e9SSH and GPG keys\u9009\u9879\u5361\uff0c\u9009\u62e9New SSH key\uff0c\u6dfb\u52a0\u516c\u94a5\u6587\u4ef6\u5185\u5bb9\u5e76\u4fdd\u5b58\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u68c0\u9a8cssh\u914d\u7f6e\u662f\u5426\u6b63\u786e<\/h2>\n\n\n\n<p>$ssh -T&nbsp;git@github.com&nbsp;<\/p>\n\n\n\n<p>\u6d4b\u8bd5\u662f\u5426\u6b63\u786e\u94fe\u63a5\u5230Git\u4ed3\u5e93.<\/p>\n\n\n\n<p>\u7a97\u53e3\u63d0\u793a:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Hi Cube-Line! You&#8217;ve successfully authenticated, but GitHub does not provide shell access.<\/p>\n<\/blockquote>\n\n\n\n<p>\u5373\u8868\u793a\u60a8\u5df2\u7ecf\u6b63\u786e\u914d\u7f6e\u597dSSH\u94fe\u63a5\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u4ed3\u5e93\u521d\u59cb\u5316<\/h2>\n\n\n\n<p>$git init<\/p>\n\n\n\n<p>\u5728\u76ee\u5f55\u4e0b\u521d\u59cb\u5316git\u4ed3\u5e93<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u6682\u5b58\u66f4\u6539<\/h2>\n\n\n\n<p>$git add .<\/p>\n\n\n\n<p>\u6682\u5b58\u5df2\u4fee\u6539\u5185\u5bb9<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u63d0\u4ea4\u6682\u5b58\u6587\u4ef6<\/h2>\n\n\n\n<p>$git commit-m &#8220;\u63cf\u8ff0\u4fe1\u606f&#8221;<\/p>\n\n\n\n<p>\u63d0\u4ea4\u6682\u5b58\u6587\u4ef6<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u516b\u3001\u5173\u8054\u8fdc\u7a0b\u4ed3\u5e93<\/h2>\n\n\n\n<p>$git remote add origin git@github.com:user.name\/xxxxxx.git<\/p>\n\n\n\n<p>\u5173\u8054\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u6ce8\u610f\u5982\u679c\u4e0d\u60f3\u6bcf\u6b21\u8f93\u5165\u5bc6\u7801\uff0c\u8bf7\u4f7f\u7528SSH\u65b9\u5f0f\u7684url(\u540c\u65f6\u8fd8\u9700\u8981\u4fdd\u8bc1\u521b\u5efassh\u5bc6\u94a5\u7684\u65f6\u5019\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801)\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e5d\u3001\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93<\/h2>\n\n\n\n<p>$git push -u origin main<\/p>\n\n\n\n<p>\u63a8\u9001\u672c\u5730\u4ed3\u5e93\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u3001\u5f3a\u5236\u8986\u76d6\u672c\u5730\u7248\u672c<\/h2>\n\n\n\n<p>$git fetch &#8211;all&nbsp;&nbsp; \/\/\u62c9\u53d6\u6240\u6709\u66f4\u65b0\uff0c\u4e0d\u540c\u6b65<br>$git reset &#8211;hard origin\/main&nbsp;&nbsp; \/\/\u672c\u5730\u4ee3\u7801\u540c\u6b65\u7ebf\u4e0a\u66f4\u65b0(\u4f1a\u8986\u76d6\u672c\u5730\u6240\u6709\u4e0e\u7ebf\u4e0a\u540c\u540d\u6587\u4ef6)<br>$git pull&nbsp; \/\/\u66f4\u65b0\u4e00\u4e0b\uff0c\u62c9\u53d6\u8fdc\u7a0b\u6587\u4ef6<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u4e00\u3001\u6ce8\u610f\u4e8b\u9879\uff1a<\/h2>\n\n\n\n<p>1\u3001\u672c\u5730\u7248\u672c\u548c\u8fdc\u7a0b\u4e0d\u4e00\u81f4\uff0c\u9700\u8981\u5408\u5e76\u51b2\u7a81<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\/\/\u67e5\u8be2\u5f53\u524d\u8fdc\u7a0b\u7684\u7248\u672c<br>$ git remote -v<br>\/\/\u83b7\u53d6\u6700\u65b0\u4ee3\u7801\u5230\u672c\u5730(\u672c\u5730\u5f53\u524d\u5206\u652f\u4e3a[branch]\uff0c\u83b7\u53d6\u7684\u8fdc\u7aef\u7684\u5206\u652f\u4e3a[origin\/branch])<br>$ git fetch origin main [\u793a\u4f8b1\uff1a\u83b7\u53d6\u8fdc\u7aef\u7684origin\/main\u5206\u652f]<br>$ git fetch origin dev [\u793a\u4f8b2\uff1a\u83b7\u53d6\u8fdc\u7aef\u7684origin\/dev\u5206\u652f]<br>\/\/\u67e5\u770b\u7248\u672c\u5dee\u5f02<br>$ git log -p master..origin\/main [\u793a\u4f8b1\uff1a\u67e5\u770b\u672c\u5730master\u4e0e\u8fdc\u7aeforigin\/main\u7684\u7248\u672c\u5dee\u5f02]<br>$ git log -p dev..origin\/dev [\u793a\u4f8b2\uff1a\u67e5\u770b\u672c\u5730dev\u4e0e\u8fdc\u7aeforigin\/dev\u7684\u7248\u672c\u5dee\u5f02]<br>\/\/\u5408\u5e76\u6700\u65b0\u4ee3\u7801\u5230\u672c\u5730\u5206\u652f<br>$ git merge origin\/main [\u793a\u4f8b1\uff1a\u5408\u5e76\u8fdc\u7aef\u5206\u652forigin\/main\u5230\u5f53\u524d\u5206\u652f]<br>$ git merge origin\/dev [\u793a\u4f8b2\uff1a\u5408\u5e76\u8fdc\u7aef\u5206\u652forigin\/dev\u5230\u5f53\u524d\u5206\u652f]<\/p>\n<cite>\u6765\u81ea:https:\/\/blog.csdn.net\/hanchao5272\/article\/details\/79162130<\/cite><\/blockquote>\n\n\n\n<p>2\u3001\u66f4\u65b0\u4ece\u8fdc\u7a0b\u62c9\u53d6\u7684\u9879\u76ee<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u539f\u4ed3\u5e93\u53c8\u6709\u66f4\u65b0\uff0c\u4f60\u53ea\u9700\u8981\u5728\u6839\u76ee\u5f55\u6267\u884c&nbsp;<span style=\"background-color: initial; font-family: inherit; text-align: initial;\">git pull<\/span>\uff0c\u7136\u540e<strong>\u52a1\u5fc5<\/strong>\u7d27\u8ddf\u4e00\u4e2a\uff1a\n$<span style=\"background-color: initial; font-family: inherit; text-align: initial; font-weight: bold;\">git submodule update --init --recursive<\/span>\n\/\/\u6709\u4e9b\u5927\u578b\u9879\u76ee\u7684\u5b50\u6a21\u7ec4\u7248\u672c\u5bf9\u9f50\u975e\u5e38\u5173\u952e<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u68c0\u67e5git\u7528\u6237\u540d\u548c\u90ae\u7bb1 $git config &#8211;global &#8211;list \u9ed8\u8ba4\u4f1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":351,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12,27],"tags":[13,16,14,15],"class_list":["post-56","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git","category-workspace","tag-git","tag-gitee","tag-github","tag-gitlab"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/turbostudio.xyz\/wp-content\/uploads\/2023\/11\/git-blog-header.png?fit=1920%2C1080&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=56"}],"version-history":[{"count":6,"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":473,"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/473"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=\/wp\/v2\/media\/351"}],"wp:attachment":[{"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/turbostudio.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}