{"id":598,"date":"2018-02-23T23:48:53","date_gmt":"2018-02-23T15:48:53","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/git-%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae\/"},"modified":"2018-02-23T23:48:53","modified_gmt":"2018-02-23T15:48:53","slug":"git-%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=598","title":{"rendered":"Git \u5b89\u88c5\u914d\u7f6e"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>Git \u5b89\u88c5\u914d\u7f6e<\/h1>\n<p>\u5728\u4f7f\u7528Git\u524d\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5 Git\u3002Git \u76ee\u524d\u652f\u6301 Linux\/Unix\u3001Solaris\u3001Mac\u548c Windows \u5e73\u53f0\u4e0a\u8fd0\u884c\u3002<\/p>\n<p>Git \u5404\u5e73\u53f0\u5b89\u88c5\u5305\u4e0b\u8f7d\u5730\u5740\u4e3a\uff1a<a href=\"http:\/\/git-scm.com\/downloads\" target=\"_blank\">http:\/\/git-scm.com\/downloads<\/a>\n<\/p>\n<hr>\n<h2>Linux \u5e73\u53f0\u4e0a\u5b89\u88c5<\/h2>\n<p>Git \u7684\u5de5\u4f5c\u9700\u8981\u8c03\u7528 curl\uff0czlib\uff0copenssl\uff0cexpat\uff0clibiconv \u7b49\u5e93\u7684\u4ee3\u7801\uff0c\u6240\u4ee5\u9700\u8981\u5148\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u5de5\u5177\u3002\n<\/p>\n<p>\u5728\u6709 yum \u7684\u7cfb\u7edf\u4e0a\uff08\u6bd4\u5982 Fedora\uff09\u6216\u8005\u6709 apt-get \u7684\u7cfb\u7edf\u4e0a\uff08\u6bd4\u5982 Debian \u4f53\u7cfb\uff09\uff0c\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5b89\u88c5\uff1a\n<\/p>\n<p>\u5404 Linux \u7cfb\u7edf\u53ef\u4ee5\u5f88\u7b80\u5355\u591a\u4f7f\u7528\u5176\u5b89\u88c5\u5305\u7ba1\u7406\u5de5\u5177\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<h3>Debian\/Ubuntu<\/h3>\n<p>Debian\/Ubuntu Git \u5b89\u88c5\u547d\u4ee4\u4e3a\uff1a<\/p>\n<pre>\n$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \\\n  libz-dev libssl-dev\n\n$ apt-get install git-core\n\n$ git --version\ngit version 1.8.1.2\n<\/pre>\n<h3>Centos\/RedHat<\/h3>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u7cfb\u7edf\u662f Centos\/RedHat \u5b89\u88c5\u547d\u4ee4\u4e3a\uff1a<\/p>\n<pre>\n$ yum install curl-devel expat-devel gettext-devel \\\n  openssl-devel zlib-devel\n\n$ yum -y install git-core\n\n$ git --version\ngit version 1.7.1\n<\/pre>\n<hr>\n<h2>Windows \u5e73\u53f0\u4e0a\u5b89\u88c5<\/h2>\n<p>\n\u5728 Windows \u5e73\u53f0\u4e0a\u5b89\u88c5 Git \u540c\u6837\u8f7b\u677e\uff0c\u6709\u4e2a\u53eb\u505a msysGit \u7684\u9879\u76ee\u63d0\u4f9b\u4e86\u5b89\u88c5\u5305\uff0c\u53ef\u4ee5\u5230 GitHub \u7684\u9875\u9762\u4e0a\u4e0b\u8f7d exe \u5b89\u88c5\u6587\u4ef6\u5e76\u8fd0\u884c\uff1a\n<\/p>\n<p>\u5b89\u88c5\u5305\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/msysgit.github.io\/\" target=\"_blank\">http:\/\/msysgit.github.io\/<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.runoob.com\/wp-content\/uploads\/2015\/02\/20140127131250906\" alt=\"Windows \u4e0a\u5b89\u88c5 Git\" width=\"523\" height=\"413\"><\/p>\n<p>\n\u5b8c\u6210\u5b89\u88c5\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u7684 git \u5de5\u5177\uff08\u5df2\u7ecf\u81ea\u5e26\u4e86 ssh \u5ba2\u6237\u7aef\uff09\u4e86\uff0c\u53e6\u5916\u8fd8\u6709\u4e00\u4e2a\u56fe\u5f62\u754c\u9762\u7684 Git \u9879\u76ee\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<p>\n\u5728\u5f00\u59cb\u83dc\u5355\u91cc\u627e\u5230&#8221;Git&#8221;-&gt;&#8221;Git Bash&#8221;\uff0c\u4f1a\u5f39\u51fa Git \u547d\u4ee4\u7a97\u53e3\uff0c\u4f60\u53ef\u4ee5\u5728\u8be5\u7a97\u53e3\u8fdb\u884c Git \u64cd\u4f5c\u3002<\/p>\n<hr>\n<h2>Mac \u5e73\u53f0\u4e0a\u5b89\u88c5<\/h2>\n<p>\n\u5728 Mac \u5e73\u53f0\u4e0a\u5b89\u88c5 Git \u6700\u5bb9\u6613\u7684\u5f53\u5c5e\u4f7f\u7528\u56fe\u5f62\u5316\u7684 Git \u5b89\u88c5\u5de5\u5177\uff0c\u4e0b\u8f7d\u5730\u5740\u4e3a\uff1a<\/p>\n<p><a href=\"http:\/\/sourceforge.net\/projects\/git-osx-installer\/\" target=\"_blank\">http:\/\/sourceforge.net\/projects\/git-osx-installer\/<\/a>\n<\/p>\n<p>\u5b89\u88c5\u754c\u9762\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.runoob.com\/wp-content\/uploads\/2015\/02\/18333fig0107-tn.png\" alt=\"18333fig0107-tn\" width=\"350\" height=\"252\"><\/p>\n<hr>\n<h2> Git \u914d\u7f6e<\/h2>\n<p>Git \u63d0\u4f9b\u4e86\u4e00\u4e2a\u53eb\u505a git config \u7684\u5de5\u5177\uff0c\u4e13\u95e8\u7528\u6765\u914d\u7f6e\u6216\u8bfb\u53d6\u76f8\u5e94\u7684\u5de5\u4f5c\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<p>\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\uff0c\u51b3\u5b9a\u4e86 Git \u5728\u5404\u4e2a\u73af\u8282\u7684\u5177\u4f53\u5de5\u4f5c\u65b9\u5f0f\u548c\u884c\u4e3a\u3002\u8fd9\u4e9b\u53d8\u91cf\u53ef\u4ee5\u5b58\u653e\u5728\u4ee5\u4e0b\u4e09\u4e2a\u4e0d\u540c\u7684\u5730\u65b9\uff1a\n<\/p>\n<ul>\n<li>  <code>\/etc\/gitconfig<\/code> \u6587\u4ef6\uff1a\u7cfb\u7edf\u4e2d\u5bf9\u6240\u6709\u7528\u6237\u90fd\u666e\u904d\u9002\u7528\u7684\u914d\u7f6e\u3002\u82e5\u4f7f\u7528 <code>git config<\/code> \u65f6\u7528 <code>--system<\/code> \u9009\u9879\uff0c\u8bfb\u5199\u7684\u5c31\u662f\u8fd9\u4e2a\u6587\u4ef6\u3002<\/li>\n<li>  <code>~\/.gitconfig<\/code> \u6587\u4ef6\uff1a\u7528\u6237\u76ee\u5f55\u4e0b\u7684\u914d\u7f6e\u6587\u4ef6\u53ea\u9002\u7528\u4e8e\u8be5\u7528\u6237\u3002\u82e5\u4f7f\u7528 <code>git config<\/code> \u65f6\u7528 <code>--global<\/code> \u9009\u9879\uff0c\u8bfb\u5199\u7684\u5c31\u662f\u8fd9\u4e2a\u6587\u4ef6\u3002<\/li>\n<li>  \u5f53\u524d\u9879\u76ee\u7684 Git \u76ee\u5f55\u4e2d\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u4e5f\u5c31\u662f\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684 <code>.git\/config<\/code> \u6587\u4ef6\uff09\uff1a\u8fd9\u91cc\u7684\u914d\u7f6e\u4ec5\u4ec5\u9488\u5bf9\u5f53\u524d\u9879\u76ee\u6709\u6548\u3002\u6bcf\u4e00\u4e2a\u7ea7\u522b\u7684\u914d\u7f6e\u90fd\u4f1a\u8986\u76d6\u4e0a\u5c42\u7684\u76f8\u540c\u914d\u7f6e\uff0c\u6240\u4ee5 <code>.git\/config<\/code> \u91cc\u7684\u914d\u7f6e\u4f1a\u8986\u76d6 <code>\/etc\/gitconfig<\/code> \u4e2d\u7684\u540c\u540d\u53d8\u91cf\u3002<\/li>\n<\/ul>\n<p>\n\u5728 Windows \u7cfb\u7edf\u4e0a\uff0cGit \u4f1a\u627e\u5bfb\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\u7684 .gitconfig \u6587\u4ef6\u3002\u4e3b\u76ee\u5f55\u5373 $HOME \u53d8\u91cf\u6307\u5b9a\u7684\u76ee\u5f55\uff0c\u4e00\u822c\u90fd\u662f C:\\Documents and Settings\\$USER\u3002<\/p>\n<p>\u6b64\u5916\uff0cGit \u8fd8\u4f1a\u5c1d\u8bd5\u627e\u5bfb \/etc\/gitconfig \u6587\u4ef6\uff0c\u53ea\u4e0d\u8fc7\u770b\u5f53\u521d Git \u88c5\u5728\u4ec0\u4e48\u76ee\u5f55\uff0c\u5c31\u4ee5\u6b64\u4f5c\u4e3a\u6839\u76ee\u5f55\u6765\u5b9a\u4f4d\u3002\n<\/p>\n<h3>\u7528\u6237\u4fe1\u606f<\/h3>\n<p>\u914d\u7f6e\u4e2a\u4eba\u7684\u7528\u6237\u540d\u79f0\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff1a<\/p>\n<pre>\n$ git config --global user.name \"runoob\"\n$ git config --global user.email test@runoob.com\n<\/pre>\n<p>\n\u5982\u679c\u7528\u4e86 <strong>&#8211;global<\/strong> \u9009\u9879\uff0c\u90a3\u4e48\u66f4\u6539\u7684\u914d\u7f6e\u6587\u4ef6\u5c31\u662f\u4f4d\u4e8e\u4f60\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\u7684\u90a3\u4e2a\uff0c\u4ee5\u540e\u4f60\u6240\u6709\u7684\u9879\u76ee\u90fd\u4f1a\u9ed8\u8ba4\u4f7f\u7528\u8fd9\u91cc\u914d\u7f6e\u7684\u7528\u6237\u4fe1\u606f\u3002<\/p>\n<p>\u5982\u679c\u8981\u5728\u67d0\u4e2a\u7279\u5b9a\u7684\u9879\u76ee\u4e2d\u4f7f\u7528\u5176\u4ed6\u540d\u5b57\u6216\u8005\u7535\u90ae\uff0c\u53ea\u8981\u53bb\u6389 &#8211;global \u9009\u9879\u91cd\u65b0\u914d\u7f6e\u5373\u53ef\uff0c\u65b0\u7684\u8bbe\u5b9a\u4fdd\u5b58\u5728\u5f53\u524d\u9879\u76ee\u7684 .git\/config \u6587\u4ef6\u91cc\u3002\n<\/p>\n<h3>\u6587\u672c\u7f16\u8f91\u5668<\/h3>\n<p>\u8bbe\u7f6eGit\u9ed8\u8ba4\u4f7f\u7528\u7684\u6587\u672c\u7f16\u8f91\u5668,<br \/>\n\u4e00\u822c\u53ef\u80fd\u4f1a\u662f Vi \u6216\u8005 Vim\u3002\u5982\u679c\u4f60\u6709\u5176\u4ed6\u504f\u597d\uff0c\u6bd4\u5982 Emacs \u7684\u8bdd\uff0c\u53ef\u4ee5\u91cd\u65b0\u8bbe\u7f6e\uff1a:<\/p>\n<pre>\n$ git config --global core.editor emacs\n<\/pre>\n<h3>\u5dee\u5f02\u5206\u6790\u5de5\u5177<\/h3>\n<p>\n\u8fd8\u6709\u4e00\u4e2a\u6bd4\u8f83\u5e38\u7528\u7684\u662f\uff0c\u5728\u89e3\u51b3\u5408\u5e76\u51b2\u7a81\u65f6\u4f7f\u7528\u54ea\u79cd\u5dee\u5f02\u5206\u6790\u5de5\u5177\u3002\u6bd4\u5982\u8981\u6539\u7528 vimdiff \u7684\u8bdd\uff1a\n<\/p>\n<pre>\n$ git config --global merge.tool vimdiff\n<\/pre>\n<p>\nGit \u53ef\u4ee5\u7406\u89e3 kdiff3\uff0ctkdiff\uff0cmeld\uff0cxxdiff\uff0cemerge\uff0cvimdiff\uff0cgvimdiff\uff0cecmerge\uff0c\u548c opendiff \u7b49\u5408\u5e76\u5de5\u5177\u7684\u8f93\u51fa\u4fe1\u606f\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4f7f\u7528\u81ea\u5df1\u5f00\u53d1\u7684\u5de5\u5177\uff0c\u5177\u4f53\u600e\u4e48\u505a\u53ef\u4ee5\u53c2\u9605\u7b2c\u4e03\u7ae0\u3002\n<\/p>\n<h3>\n\u67e5\u770b\u914d\u7f6e\u4fe1\u606f<\/h3>\n<p>\n\u8981\u68c0\u67e5\u5df2\u6709\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528 git config &#8211;list \u547d\u4ee4\uff1a\n<\/p>\n<pre>\n$ git config --list\nhttp.postbuffer=2M\nuser.name=runoob\nuser.email=test@runoob.com\n<\/pre>\n<p>\n\u6709\u65f6\u5019\u4f1a\u770b\u5230\u91cd\u590d\u7684\u53d8\u91cf\u540d\uff0c\u90a3\u5c31\u8bf4\u660e\u5b83\u4eec\u6765\u81ea\u4e0d\u540c\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u6bd4\u5982 \/etc\/gitconfig \u548c ~\/.gitconfig\uff09\uff0c\u4e0d\u8fc7\u6700\u7ec8 Git \u5b9e\u9645\u91c7\u7528\u7684\u662f\u6700\u540e\u4e00\u4e2a\u3002\n<\/p>\n<p>\u8fd9\u4e9b\u914d\u7f6e\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728 <strong>~\/.gitconfig<\/strong> \u6216 <strong>\/etc\/gitconfig<\/strong> \u770b\u5230\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>\nvim ~\/.gitconfig \n<\/pre>\n<p>\u663e\u793a\u5185\u5bb9\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>\n[http]\n    postBuffer = 2M\n[user]\n    name = runoob\n    email = test@runoob.com\n<\/pre>\n<p>\n\u4e5f\u53ef\u4ee5\u76f4\u63a5\u67e5\u9605\u67d0\u4e2a\u73af\u5883\u53d8\u91cf\u7684\u8bbe\u5b9a\uff0c\u53ea\u8981\u628a\u7279\u5b9a\u7684\u540d\u5b57\u8ddf\u5728\u540e\u9762\u5373\u53ef\uff0c\u50cf\u8fd9\u6837\uff1a\n<\/p>\n<pre>\n$ git config user.name\nrunoob\n<\/pre>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">Git \u5b89\u88c5\u914d\u7f6e \u5728\u4f7f\u7528Git\u524d\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5 Git\u3002Git \u76ee\u524d\u652f\u6301 Linux\/Un&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=598\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[64,137],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-git","tag-git","tag-tool","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=598"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/598\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}