{"id":231532,"date":"2021-12-18T09:04:21","date_gmt":"2021-12-18T01:04:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=231532"},"modified":"2021-12-09T10:15:38","modified_gmt":"2021-12-09T02:15:38","slug":"ubuntu-setup-git","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ubuntu-setup-git.html","title":{"rendered":"Ubuntu 20.04\u4e0a\u5b89\u88c5Git\u65b9\u6cd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nGit\u662f\u4e16\u754c\u4e0a\u6700\u53d7\u6b22\u8fce\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u88ab\u8bb8\u591a\u5f00\u6e90\u548c\u5546\u4e1a\u9879\u76ee\u4f7f\u7528\u3002\u5b83\u4f7f\u60a8\u53ef\u4ee5\u4e0e\u5176\u4ed6\u5f00\u53d1\u4eba\u5458\u5728\u9879\u76ee\u4e0a\u8fdb\u884c\u534f\u4f5c\uff0c\u8ddf\u8e2a\u4ee3\u7801\u66f4\u6539\uff0c\u8fd8\u539f\u5230\u4e0a\u4e00\u9636\u6bb5\uff0c\u521b\u5efa\u5206\u652f\u7b49\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Git\u6700\u521d\u662f\u7531Linux\u5185\u6838\u7684\u521b\u5efa\u8005Linus Torvalds\u5f00\u53d1\u7684\u3002\u672c\u6307\u5357\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Ubuntu 20.04\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eGit\u3002<\/p>\n

\u4f7f\u7528Apt\u5b89\u88c5Git<\/strong><\/div>\n

Git\u8f6f\u4ef6\u5305\u5305\u542b\u5728Ubuntu\u7684\u9ed8\u8ba4\u5b58\u50a8\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528apt\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\u3002\u8fd9\u662f\u5728Ubuntu\u4e0a\u5b89\u88c5Git\u7684\u6700\u65b9\u4fbf\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u3002
\n\u5982\u679c\u8981\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u6700\u65b0\u7684\u7a33\u5b9a\u7248Git\uff0c\u8bf7\u8f6c\u5230\u672c\u6559\u7a0b\u7684\u201c\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5Git\u201d\u90e8\u5206\u3002
\n\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u4ee5\u5177\u6709sudo\u7279\u6743\u7684\u7528\u6237\u8eab\u4efd\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n

$ sudo apt update\r\n$ sudo apt install git<\/pre>\n

\"\"<\/p>\n

\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u5b89\u88c5\uff0c\u8be5\u547d\u4ee4\u5c06\u6253\u5370Git\u7248\u672c\uff1a<\/p>\n

$ git --version<\/pre>\n

\u5728\u64b0\u5199\u672c\u6587\u65f6\uff0cUbuntu 20.04\u5b58\u50a8\u5e93\u4e2d\u53ef\u7528\u7684Git\u5f53\u524d\u7248\u672c\u4e3a2.25.1\uff1agit version 2.25.1<\/p>\n

\"\"<\/p>\n

\u5c31\u8fd9\u6837\uff0c\u60a8\u5df2\u7ecf\u5728Ubuntu\u4e0a\u6210\u529f\u5b89\u88c5\u4e86Git\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u5b83\u4e86\u3002<\/p>\n

\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5Git<\/strong><\/div>\n

\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5Git\u7684\u4e3b\u8981\u4f18\u70b9\u662f\u60a8\u53ef\u4ee5\u7f16\u8bd1\u6700\u65b0\u7684Git\u7248\u672c\u5e76\u81ea\u5b9a\u4e49\u6784\u5efa\u9009\u9879\u3002\u4f46\u662f\uff0c\u60a8\u5c06\u65e0\u6cd5\u901a\u8fc7apt\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u6765\u7ef4\u62a4Git\u5b89\u88c5\u3002
\n\u9996\u5148\u5b89\u88c5\u5728Ubuntu\u7cfb\u7edf\u4e0a\u6784\u5efaGit\u6240\u9700\u7684\u4f9d\u8d56\u9879\uff1a<\/p>\n

sudo apt update$sudo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev make gettext libz-dev libssl-dev libghc-zlib-dev<\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8bbf\u95eeGitHub\u4e0aGit\u9879\u76ee\u7684\u955c\u50cf\uff0c\u5e76\u590d\u5236\u4ee5.tar.gz\u7ed3\u5c3e\u7684\u6700\u65b0\u53d1\u884c\u7248\u94fe\u63a5URL\u3002\u5728\u64b0\u5199\u672c\u6587\u65f6\uff0c\u6700\u65b0\u7684\u7a33\u5b9aGit\u7248\u672c\u662f\u201c 2.26.2\u201d\uff1a
\n\u6211\u4eec\u5c06\u5728\/usr\/src\u76ee\u5f55\u4e2d\u4e0b\u8f7d\u5e76\u89e3\u538b\u7f29Git\u6e90\u4ee3\u7801\uff0c\u8be5\u76ee\u5f55\u662f\u653e\u7f6e\u6e90\u6587\u4ef6\u7684\u5e38\u7528\u4f4d\u7f6e\uff1a<\/p>\n

wget -c https:\/\/github.com\/git\/git\/archive\/v2.26.2.tar.gz -O - | sudo tar -xz -C \/usr\/src<\/pre>\n

\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8f6c\u5230\u6e90\u76ee\u5f55\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u7f16\u8bd1\u548c\u5b89\u88c5Git\uff1a<\/p>\n

cd \/usr\/src\/git-*\r\nsudo make prefix=\/usr\/local all\r\nsudo make prefix=\/usr\/local install<\/pre>\n

\u7f16\u8bd1\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u51e0\u5206\u949f\u3002\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u5b89\u88c5\uff1a<\/p>\n

$ $git --version\r\ngit version 2.26.2<\/pre>\n

\u4ee5\u540e\uff0c\u5f53\u60a8\u60f3\u5347\u7ea7\u5230\u8f83\u65b0\u7248\u672c\u7684Git\u65f6\uff0c\u8bf7\u4f7f\u7528\u76f8\u540c\u7684\u8fc7\u7a0b\u3002<\/p>\n

\u914d\u7f6eGit<\/strong><\/div>\n

\u5b89\u88c5Git\u4e4b\u540e\uff0c\u60a8\u9700\u8981\u505a\u7684\u7b2c\u4e00\u4ef6\u4e8b\u5c31\u662f\u914d\u7f6e\u60a8\u7684git\u7528\u6237\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002 Git\u5c06\u60a8\u7684\u8eab\u4efd\u4e0e\u60a8\u6240\u505a\u7684\u6bcf\u6b21\u63d0\u4ea4\u76f8\u5173\u8054\u3002
\n\u8981\u8bbe\u7f6e\u5168\u5c40\u63d0\u4ea4\u540d\u79f0\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

$ git config --global user.name \"linuxidc\"\r\n$ git config --global user.email root@linuxidc.net<\/pre>\n

\"\"<\/p>\n

\u60a8\u53ef\u4ee5\u901a\u8fc7\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u914d\u7f6e\u66f4\u6539\uff1a<\/p>\n

$ git config --list<\/pre>\n

\"\"<\/p>\n

\u8f93\u51fa\u5e94\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

user.name=linuxidc\r\nuser.email=root@linuxidc.net<\/pre>\n

\u914d\u7f6e\u8bbe\u7f6e\u5b58\u50a8\u5728~\/.gitconfig\u6587\u4ef6\u4e2d\uff1a<\/p>\n

~\/.gitconfig\r\n\r\n[user]\r\n            user.name=linuxidc\r\n           user.email=root@linuxidc.net<\/pre>\n

\u5982\u679c\u8981\u5bf9Git\u914d\u7f6e\u8fdb\u884c\u8fdb\u4e00\u6b65\u66f4\u6539\uff0c\u53ef\u4ee5\u4f7f\u7528git config\u547d\u4ee4\uff08\u63a8\u8350\uff09\u6216\u624b\u52a8\u7f16\u8f91~\/.gitconfig\u6587\u4ef6\u3002<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u5728Ubuntu\u4e0a\u5b89\u88c5Git\u662f\u8fd0\u884c\u5355\u4e2aapt\u547d\u4ee4\u7684\u95ee\u9898\u3002\u5982\u679c\u8981\u4f7f\u7528\u6700\u65b0\u7684Git\u7248\u672c\uff0c\u53ef\u4ee5\u4ece\u6e90\u4ee3\u7801\u8fdb\u884c\u7f16\u8bd1\u3002
\n\u8981\u4e86\u89e3\u6709\u5173Git\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u8bbf\u95eePro Git book\u7f51\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Git\u6700\u521d\u662f\u7531Linux\u5185\u6838\u7684\u521b\u5efa\u8005Linus Torvalds\u5f00\u53d1\u7684\u3002\u672c\u6307\u5357\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Ubuntu 20. […]<\/p>\n","protected":false},"author":310,"featured_media":231560,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-231532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/231532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=231532"}],"version-history":[{"count":12,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/231532\/revisions"}],"predecessor-version":[{"id":231785,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/231532\/revisions\/231785"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/231560"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=231532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=231532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=231532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}