{"id":16190,"date":"2024-11-18T12:02:31","date_gmt":"2024-11-18T04:02:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/16190\/"},"modified":"2024-11-18T12:02:31","modified_gmt":"2024-11-18T04:02:31","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8linux%e4%b8%8a%e5%ae%89%e8%a3%85%e5%92%8c%e9%85%8d%e7%bd%aegit%e7%89%88%e6%9c%ac%e6%8e%a7%e5%88%b6%e7%b3%bb%e7%bb%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/16190\/","title":{"rendered":"\u5982\u4f55\u5728Linux\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eGit\u7248\u672c\u63a7\u5236\u7cfb\u7edf"},"content":{"rendered":"<p>\u5982\u4f55\u5728linux\u4e0a\u5b89\u88c5\u548c\u914d\u7f6egit\u7248\u672c\u63a7\u5236\u7cfb\u7edf<\/p>\n<p>\u5f15\u8a00\uff1a<br \/>Git\u662f\u4e00\u6b3e\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u8f6f\u4ef6\u5f00\u53d1\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u8ffd\u8e2a\u6587\u4ef6\u7684\u53d8\u66f4\uff0c\u534f\u8c03\u591a\u4eba\u534f\u4f5c\u4ee5\u53ca\u7ba1\u7406\u7248\u672c\u7684\u53d1\u5e03\u3002\u5728Linux\u7cfb\u7edf\u4e2d\u5b89\u88c5\u548c\u914d\u7f6eGit\u662f\u975e\u5e38\u7b80\u5355\u7684\uff0c\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728linux\u4e0a\u5b89\u88c5\u548c\u914d\u7f6egit\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u3002<\/p>\n<p>\u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5Git<br \/>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5Git\u3002\u4ee5\u4e0b\u662f\u5728\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u4e0a\u5b89\u88c5Git\u7684\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li>\n<p>\u5728Debian\/Ubuntu\u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo apt-get update\nsudo apt-get install git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>\u5728CentOS\/Fedora\u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo yum update\nsudo yum install git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>\u5728Arch Linux\u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo pacman -Syu\nsudo pacman -S git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<\/ol>\n<p>\u6b65\u9aa4\u4e8c\uff1a\u914d\u7f6eGit<br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6eGit\u7684\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f\uff0c\u4ee5\u4fbf\u4e8e\u540e\u7eed\u4f7f\u7528\u3002\u4ee5\u4e0b\u662f\u914d\u7f6eGit\u7684\u547d\u4ee4\u548c\u793a\u4f8b\uff1a<\/p>\n<ol>\n<li>\n<p>\u914d\u7f6e\u7528\u6237\u540d\u548c\u90ae\u7bb1\uff1a<\/p>\n<pre>git config --global user.name \"Your Name\"\ngit config --global user.email \"your-email@example.com\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>git config --global user.name \"John Doe\"\ngit config --global user.email \"johndoe@example.com\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>\u914d\u7f6e\u9ed8\u8ba4\u7684\u6587\u672c\u7f16\u8f91\u5668\uff1a<\/p>\n<pre>git config --global core.editor \"editor_name\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u914d\u7f6e\u4e3a\u4f7f\u7528Nano\u7f16\u8f91\u5668\uff1a<\/p>\n<pre>git config --global core.editor \"nano\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>\u67e5\u770b\u914d\u7f6e\u4fe1\u606f\uff1a<\/p>\n<pre>git config --list<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u5c06\u5217\u51fa\u5f53\u524dGit\u7684\u914d\u7f6e\u4fe1\u606f\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u6b65\u9aa4\u4e09\uff1a\u521b\u5efaGit\u4ed3\u5e93<br \/>\u5b8c\u6210Git\u7684\u5b89\u88c5\u548c\u914d\u7f6e\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\uff0c\u4ee5\u4fbf\u4e8e\u5f00\u59cb\u7248\u672c\u63a7\u5236\u3002\u4ee5\u4e0b\u662f\u521b\u5efaGit\u4ed3\u5e93\u7684\u547d\u4ee4\u548c\u793a\u4f8b\uff1a<\/p>\n<ol>\n<li>\n<p>\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u65b0\u7684\u4ed3\u5e93\uff1a<\/p>\n<pre>git init<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;.git&#8221;\u7684\u9690\u85cf\u6587\u4ef6\u5939\uff0c\u8be5\u6587\u4ef6\u5939\u7528\u4e8e\u5b58\u50a8Git\u7684\u7248\u672c\u63a7\u5236\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p>\u514b\u9686\u4e00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<pre>git clone remote_repository_url<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u514b\u9686GitHub\u4e0a\u7684\u4e00\u4e2a\u4ed3\u5e93\uff1a<\/p>\n<pre>git clone https:\/\/github.com\/user\/repo.git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u5c06\u514b\u9686\u6307\u5b9a\u7684\u4ed3\u5e93\u5230\u672c\u5730\uff0c\u5e76\u81ea\u52a8\u5c06\u8fdc\u7a0b\u4ed3\u5e93\u8bbe\u7f6e\u4e3a&#8221;origin&#8221;\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u6b65\u9aa4\u56db\uff1a\u5e38\u7528Git\u64cd\u4f5c<br \/>\u5b8c\u6210\u4ed3\u5e93\u7684\u521b\u5efa\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528Git\u8fdb\u884c\u7248\u672c\u63a7\u5236\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684Git\u64cd\u4f5c\u547d\u4ee4\u548c\u793a\u4f8b\uff1a<\/p>\n<ol>\n<li>\n<p>\u6dfb\u52a0\u6587\u4ef6\u5230\u6682\u5b58\u533a\uff1a<\/p>\n<pre>git add file_name<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a&#8221;example.txt&#8221;\u7684\u6587\u4ef6\uff1a<\/p>\n<pre>git add example.txt<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>\u63d0\u4ea4\u6587\u4ef6\u5230\u672c\u5730\u4ed3\u5e93\uff1a<\/p>\n<pre>git commit -m \"commit_message\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u63d0\u4ea4\u6587\u4ef6\u5e76\u6dfb\u52a0\u63d0\u4ea4\u6d88\u606f\uff1a<\/p>\n<pre>git commit -m \"Add example.txt file\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u66f4\u6539\uff1a<\/p>\n<pre>git pull origin branch_name<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u66f4\u6539\u5230\u5f53\u524d\u5206\u652f\uff1a<\/p>\n<pre>git pull origin master<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>\u63a8\u9001\u672c\u5730\u4ed3\u5e93\u7684\u66f4\u6539\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<pre>git push origin branch_name<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u63a8\u9001\u672c\u5730\u4ed3\u5e93\u7684\u66f4\u6539\u5230\u8fdc\u7a0b\u4ed3\u5e93\u7684master\u5206\u652f\uff1a<\/p>\n<pre>git push origin master<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<\/ol>\n<p>\u7ed3\u8bba\uff1a<br \/>\u901a\u8fc7\u4ee5\u4e0a\u7b80\u5355\u7684\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5728Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eGit\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u4ee5\u53ca\u4f7f\u7528Git\u8fdb\u884c\u5e38\u89c1\u7684\u7248\u672c\u63a7\u5236\u64cd\u4f5c\u3002Git\u7684\u529f\u80fd\u5f3a\u5927\u4e14\u6613\u4e8e\u4f7f\u7528\uff0c\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406\u4ee3\u7801\u7684\u7248\u672c\u548c\u53d8\u66f4\uff0c\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\uff0c\u4e3a\u8f6f\u4ef6\u5f00\u53d1\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u652f\u6301\u3002\u5927\u5bb6\u5feb\u6765\u5c1d\u8bd5\u5728\u81ea\u5df1\u7684Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eGit\u5427\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728Linux\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eGit\u7248\u672c\u63a7\u5236\u7cfb\u7edf\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>\u5982\u4f55\u5728linux\u4e0a\u5b89\u88c5\u548c\u914d\u7f6egit\u7248\u672c\u63a7\u5236\u7cfb\u7edf \u5f15\u8a00\uff1aGit\u662f\u4e00\u6b3e\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u8f6f\u4ef6\u5f00\u53d1\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u8ffd\u8e2a\u6587\u4ef6\u7684\u53d8\u66f4\uff0c\u534f\u8c03\u591a\u4eba\u534f\u4f5c\u4ee5\u53ca\u7ba1\u7406\u7248\u672c\u7684\u53d1\u5e03\u3002\u5728Linux\u7cfb\u7edf\u4e2d\u5b89\u88c5\u548c\u914d\u7f6eGit\u662f\u975e\u5e38\u7b80\u5355\u7684\uff0c\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728linux\u4e0a\u5b89\u88c5\u548c\u914d\u7f6egit\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u3002 \u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5Git\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5Git\u3002\u4ee5\u4e0b\u662f\u5728\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u4e0a\u5b89\u88c5Git\u7684\u65b9\u6cd5\uff1a \u5728Debian\/Ubuntu\u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo apt-get update sudo apt-get install git \u767b\u5f55\u540e\u590d\u5236 \u5728CentOS\/Fedora\u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo yum update sudo yum install git \u767b\u5f55\u540e\u590d\u5236 \u5728Arch Linux\u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo pacman -Syu sudo pacman -S git \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4\u4e8c\uff1a\u914d\u7f6eGit\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6eGit\u7684\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f\uff0c\u4ee5\u4fbf\u4e8e\u540e\u7eed\u4f7f\u7528\u3002\u4ee5\u4e0b\u662f\u914d\u7f6eGit\u7684\u547d\u4ee4\u548c\u793a\u4f8b\uff1a \u914d\u7f6e\u7528\u6237\u540d\u548c\u90ae\u7bb1\uff1a git config &#8211;global user.name &#8220;Your Name&#8221; git config &#8211;global user.email &#8220;your-email@example.com&#8221; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff1a git config &#8211;global user.name &#8220;John Doe&#8221; git config &#8211;global [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-16190","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16190","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=16190"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16190\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=16190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=16190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=16190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}