{"id":21477,"date":"2024-11-19T10:06:17","date_gmt":"2024-11-19T02:06:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21477\/"},"modified":"2024-11-19T10:06:17","modified_gmt":"2024-11-19T02:06:17","slug":"git%e4%b8%8b%e8%bd%bd%e5%90%8e%e9%9c%80%e8%a6%81%e8%ae%be%e7%bd%ae%e4%bb%80%e4%b9%88%e5%90%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21477\/","title":{"rendered":"Git\u4e0b\u8f7d\u540e\u9700\u8981\u8bbe\u7f6e\u4ec0\u4e48\u5417"},"content":{"rendered":"<blockquote><p>\n  \u5b89\u88c5 git \u540e\uff0c\u4e3a\u4e86\u66f4\u6709\u6548\u5730\u4f7f\u7528\uff0c\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u8bbe\u7f6e\uff1a\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f\uff08\u59d3\u540d\u548c\u90ae\u7bb1\uff09\u9009\u62e9\u6587\u672c\u7f16\u8f91\u5668\u8bbe\u7f6e\u5916\u90e8\u5408\u5e76\u5de5\u5177\u751f\u6210 ssh \u79d8\u94a5\u8bbe\u7f6e\u5ffd\u7565\u6587\u4ef6\u6a21\u5f0f\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053018214023534.jpg\" class=\"aligncenter\" title=\"Git\u4e0b\u8f7d\u540e\u9700\u8981\u8bbe\u7f6e\u4ec0\u4e48\u5417\u63d2\u56fe\" alt=\"Git\u4e0b\u8f7d\u540e\u9700\u8981\u8bbe\u7f6e\u4ec0\u4e48\u5417\u63d2\u56fe\" \/><\/p>\n<p><strong>Git \u4e0b\u8f7d\u540e\u7684\u5fc5\u8981\u8bbe\u7f6e<\/strong><\/p>\n<p>\u5b89\u88c5 Git \u540e\uff0c\u4e3a\u4e86\u66f4\u6709\u6548\u5730\u4f7f\u7528\u5b83\uff0c\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u5fc5\u8981\u8bbe\u7f6e\uff1a<\/p>\n<p><strong>1. \u7528\u6237\u4fe1\u606f\u8bbe\u7f6e<\/strong><\/p>\n<p>Git \u5c06\u5728\u6bcf\u4e2a\u63d0\u4ea4\u4e2d\u8bb0\u5f55\u7528\u6237\u7684\u59d3\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002\u8fd9\u4e9b\u4fe1\u606f\u7528\u4e8e\u8bc6\u522b\u63d0\u4ea4\u8005\u548c\u8ddf\u8e2a\u8d21\u732e\u3002\u8981\u5728 Git \u4e2d\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git config --global user.name \"Your Name\"\n$ git config --global user.email \"your@email.address\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u7f16\u8f91\u5668\u8bbe\u7f6e<\/strong><\/p>\n<p>Git \u5141\u8bb8\u7528\u6237\u9009\u62e9\u4ed6\u4eec\u559c\u6b22\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u7528\u4e8e\u7f16\u8f91\u63d0\u4ea4\u6d88\u606f\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u8981\u8bbe\u7f6e\u7f16\u8f91\u5668\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git config --global core.editor \"Text Editor\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5e38\u89c1\u7684\u7f16\u8f91\u5668\u5305\u62ec Vim\u3001Nano \u548c Sublime Text\u3002<\/p>\n<p><strong>3. \u5916\u90e8\u5408\u5e76\u5de5\u5177\u8bbe\u7f6e<\/strong><\/p>\n<p>\u5728 Git \u4e2d\u5408\u5e76\u5206\u652f\u65f6\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u51b2\u7a81\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u51b2\u7a81\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u5916\u90e8\u5408\u5e76\u5de5\u5177\u3002\u8981\u5728 Git \u4e2d\u8bbe\u7f6e\u5916\u90e8\u5408\u5e76\u5de5\u5177\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git config --global mergetool.keepbackup true\n$ git config --global mergetool.tool \"Merge Tool\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5e38\u89c1\u7684\u5408\u5e76\u5de5\u5177\u5305\u62ec Meld \u548c KDiff3\u3002<\/p>\n<p><strong>4. SSH \u79d8\u94a5\u751f\u6210<\/strong><\/p>\n<p>\u5728 GitHub \u7b49 Git \u4ed3\u5e93\u6258\u7ba1\u5e73\u53f0\u4e0a\u63a8\u9001\u548c\u62c9\u53d6\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 SSH \u79d8\u94a5\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002\u8fd9\u6bd4\u4f7f\u7528\u5bc6\u7801\u66f4\u5b89\u5168\u3002\u8981\u751f\u6210 SSH \u79d8\u94a5\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ ssh-keygen -t rsa -b 4096 -C \"your@email.address\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u751f\u6210\u7684\u79d8\u94a5\u6dfb\u52a0\u5230 SSH \u4ee3\u7406\u4e2d\uff0c\u4ee5\u4fbf Git \u53ef\u4ee5\u81ea\u52a8\u4f7f\u7528\u5b83\u4eec\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n<p><strong>5. \u5ffd\u7565\u6587\u4ef6\u6a21\u5f0f\u8bbe\u7f6e<\/strong><\/p>\n<p>\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u4f1a\u4ea7\u751f\u4e00\u4e9b\u4e0d\u5e94\u6dfb\u52a0\u5230 Git \u4ed3\u5e93\u7684\u6587\u4ef6\uff0c\u4f8b\u5982\u6784\u5efa\u5de5\u4ef6\u6216 IDE \u914d\u7f6e\u6587\u4ef6\u3002\u8981\u5ffd\u7565\u8fd9\u4e9b\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git config --global core.excludesfile ~\/.gitignore_global<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\uff0c\u5c06\u8981\u5ffd\u7565\u7684\u6587\u4ef6\u6a21\u5f0f\u6dfb\u52a0\u5230 ~\/.ignore_global \u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u4ee5\u4e0a\u6b65\u9aa4\u5c06\u5e2e\u52a9\u60a8\u5728\u5b89\u88c5 Git \u540e\u66f4\u6709\u6548\u5730\u4f7f\u7528\u5b83\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fGit\u4e0b\u8f7d\u540e\u9700\u8981\u8bbe\u7f6e\u4ec0\u4e48\u5417\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>\u5b89\u88c5 git \u540e\uff0c\u4e3a\u4e86\u66f4\u6709\u6548\u5730\u4f7f\u7528\uff0c\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u8bbe\u7f6e\uff1a\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f\uff08\u59d3\u540d\u548c\u90ae\u7bb1\uff09\u9009\u62e9\u6587\u672c\u7f16\u8f91\u5668\u8bbe\u7f6e\u5916\u90e8\u5408\u5e76\u5de5\u5177\u751f\u6210 ssh \u79d8\u94a5\u8bbe\u7f6e\u5ffd\u7565\u6587\u4ef6\u6a21\u5f0f Git \u4e0b\u8f7d\u540e\u7684\u5fc5\u8981\u8bbe\u7f6e \u5b89\u88c5 Git \u540e\uff0c\u4e3a\u4e86\u66f4\u6709\u6548\u5730\u4f7f\u7528\u5b83\uff0c\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u5fc5\u8981\u8bbe\u7f6e\uff1a 1. \u7528\u6237\u4fe1\u606f\u8bbe\u7f6e Git \u5c06\u5728\u6bcf\u4e2a\u63d0\u4ea4\u4e2d\u8bb0\u5f55\u7528\u6237\u7684\u59d3\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002\u8fd9\u4e9b\u4fe1\u606f\u7528\u4e8e\u8bc6\u522b\u63d0\u4ea4\u8005\u548c\u8ddf\u8e2a\u8d21\u732e\u3002\u8981\u5728 Git \u4e2d\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a $ git config &#8211;global user.name &#8220;Your Name&#8221; $ git config &#8211;global user.email &#8220;your@email.address&#8221; \u767b\u5f55\u540e\u590d\u5236 2. \u7f16\u8f91\u5668\u8bbe\u7f6e Git \u5141\u8bb8\u7528\u6237\u9009\u62e9\u4ed6\u4eec\u559c\u6b22\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u7528\u4e8e\u7f16\u8f91\u63d0\u4ea4\u6d88\u606f\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u8981\u8bbe\u7f6e\u7f16\u8f91\u5668\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a $ git config &#8211;global core.editor &#8220;Text Editor&#8221; \u767b\u5f55\u540e\u590d\u5236 \u5e38\u89c1\u7684\u7f16\u8f91\u5668\u5305\u62ec Vim\u3001Nano \u548c Sublime Text\u3002 3. \u5916\u90e8\u5408\u5e76\u5de5\u5177\u8bbe\u7f6e \u5728 Git \u4e2d\u5408\u5e76\u5206\u652f\u65f6\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u51b2\u7a81\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u51b2\u7a81\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u5916\u90e8\u5408\u5e76\u5de5\u5177\u3002\u8981\u5728 Git \u4e2d\u8bbe\u7f6e\u5916\u90e8\u5408\u5e76\u5de5\u5177\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a $ [&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-21477","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21477","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=21477"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21477\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}