{"id":19142,"date":"2024-11-19T14:23:52","date_gmt":"2024-11-19T06:23:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19142\/"},"modified":"2024-11-19T14:23:52","modified_gmt":"2024-11-19T06:23:52","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8centos%e4%b8%8a%e5%ae%89%e8%a3%85%e5%92%8c%e4%bd%bf%e7%94%a8git","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19142\/","title":{"rendered":"\u5982\u4f55\u5728CentOS\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528Git"},"content":{"rendered":"<p>\u6982\u8ff0<\/p>\n<p>Git\u662f\u4e00\u6b3e\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u5de5\u5177\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u3002CentOS\u662f\u4e00\u79cd\u6d41\u884c\u7684Linux\u64cd\u4f5c\u7cfb\u7edf\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728CentOS\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528Git\u3002<\/p>\n<p>\u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5Git<\/p>\n<p>\u5728CentOS\u4e0a\u5b89\u88c5Git\u975e\u5e38\u5bb9\u6613\u3002\u53ea\u9700\u6253\u5f00\u7ec8\u7aef\uff0c\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo yum install git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>CentOS\u5c06\u81ea\u52a8\u4e0b\u8f7d\u548c\u5b89\u88c5Git\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1Git\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<pre>git --version<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u4f1a\u663e\u793aGit\u7684\u7248\u672c\u53f7\u3002<\/p>\n<p>\u6b65\u9aa4\u4e8c\uff1a\u914d\u7f6eGit<\/p>\n<p>\u5b89\u88c5Git\u540e\uff0c\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u57fa\u672c\u914d\u7f6e\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u8bbe\u7f6e\u60a8\u7684\u7528\u6237\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002\u8981\u8bbe\u7f6e\u7528\u6237\u540d\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git config --global user.name \"Your Name\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06\u201cYour Name\u201d\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u59d3\u540d\u3002\u5bf9\u4e8e\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git config --global user.email \"youremail@yourdomain.com\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06\u201cyouremail@yourdomain.com\u201d\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002<\/p>\n<p>\u6b65\u9aa4\u4e09\uff1a\u521b\u5efaGit\u4ed3\u5e93<\/p>\n<p>\u8981\u4f7f\u7528Git\uff0c\u60a8\u9700\u8981\u9996\u5148\u521b\u5efa\u4e00\u4e2aGit\u4ed3\u5e93\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u4f7f\u7528GUI\u5de5\u5177\u5b8c\u6210\u3002\u4ee5\u4e0b\u662f\u7528\u547d\u4ee4\u884c\u521b\u5efaGit\u4ed3\u5e93\u7684\u793a\u4f8b\uff1a<\/p>\n<pre>mkdir myproject\ncd myproject\ngit init<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u5c06\u5728\u60a8\u7684\u4e3b\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyproject\u201d\u7684\u76ee\u5f55\uff0c\u5e76\u5728\u5176\u4e2d\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\u3002<\/p>\n<p>\u6b65\u9aa4\u56db\uff1a\u6dfb\u52a0\u6587\u4ef6<\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230Git\u4ed3\u5e93\u4e2d\u3002\u8981\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230Git\u4ed3\u5e93\u4e2d\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git add filename<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u60a8\u53ef\u4ee5\u5c06\u201cfilename\u201d\u66ff\u6362\u4e3a\u60a8\u8981\u6dfb\u52a0\u7684\u5b9e\u9645\u6587\u4ef6\u540d\u3002\u5982\u679c\u8981\u5c06\u6240\u6709\u6587\u4ef6\u6dfb\u52a0\u5230Git\u4ed3\u5e93\u4e2d\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git add .<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b65\u9aa4\u4e94\uff1a\u63d0\u4ea4\u66f4\u6539<\/p>\n<p>\u5f53\u60a8\u5bf9\u6587\u4ef6\u8fdb\u884c\u66f4\u6539\u540e\uff0c\u9700\u8981\u5c06\u66f4\u6539\u63d0\u4ea4\u5230Git\u4ed3\u5e93\u4e2d\u3002\u8981\u63d0\u4ea4\u66f4\u6539\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git commit -m \"Commit message\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06\u201cCommit message\u201d\u66ff\u6362\u4e3a\u60a8\u8981\u63d0\u4ea4\u7684\u6d88\u606f\u3002\u8fd9\u5c06\u4f7f\u60a8\u7684\u66f4\u6539\u6210\u4e3aGit\u4ed3\u5e93\u7684\u4e00\u90e8\u5206\u3002<\/p>\n<p>\u6b65\u9aa4\u516d\uff1a\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528Git\u6765\u8fdb\u884c\u534f\u4f5c\u5f00\u53d1\uff0c\u53ef\u4ee5\u5c06\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002\u8981\u63a8\u9001\u66f4\u6539\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git push origin master<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u201corigin\u201d\u548c\u201cmaster\u201d\u662f\u9ed8\u8ba4\u8bbe\u7f6e\uff0c\u60a8\u53ef\u4ee5\u5c06\u5176\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u8fdc\u7a0b\u4ed3\u5e93\u540d\u79f0\u548c\u5206\u652f\u540d\u79f0\u3002<\/p>\n<p>\u7ed3\u675f\u8bed<\/p>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u7b80\u5355\u7684\u6559\u7a0b\uff0c\u60a8\u73b0\u5728\u5e94\u8be5\u77e5\u9053\u5982\u4f55\u5728CentOS\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528Git\u4e86\u3002\u4f7f\u7528Git\u8fdb\u884c\u7248\u672c\u63a7\u5236\u662f\u4e00\u9879\u975e\u5e38\u91cd\u8981\u7684\u8f6f\u4ef6\u5f00\u53d1\u5b9e\u8df5\uff0c\u4e5f\u5c06\u5e2e\u52a9\u60a8\u66f4\u8f7b\u677e\u5730\u534f\u4f5c\u5f00\u53d1\u3002\u795d\u60a8\u4f7f\u7528Git\u6109\u5feb\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728CentOS\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528Git\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>\u6982\u8ff0 Git\u662f\u4e00\u6b3e\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u5de5\u5177\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u3002CentOS\u662f\u4e00\u79cd\u6d41\u884c\u7684Linux\u64cd\u4f5c\u7cfb\u7edf\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728CentOS\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528Git\u3002 \u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5Git \u5728CentOS\u4e0a\u5b89\u88c5Git\u975e\u5e38\u5bb9\u6613\u3002\u53ea\u9700\u6253\u5f00\u7ec8\u7aef\uff0c\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo yum install git \u767b\u5f55\u540e\u590d\u5236 CentOS\u5c06\u81ea\u52a8\u4e0b\u8f7d\u548c\u5b89\u88c5Git\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1Git\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a git &#8211;version \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u4f1a\u663e\u793aGit\u7684\u7248\u672c\u53f7\u3002 \u6b65\u9aa4\u4e8c\uff1a\u914d\u7f6eGit \u5b89\u88c5Git\u540e\uff0c\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u57fa\u672c\u914d\u7f6e\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u8bbe\u7f6e\u60a8\u7684\u7528\u6237\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002\u8981\u8bbe\u7f6e\u7528\u6237\u540d\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a git config &#8211;global user.name &#8220;Your Name&#8221; \u767b\u5f55\u540e\u590d\u5236 \u5c06\u201cYour Name\u201d\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u59d3\u540d\u3002\u5bf9\u4e8e\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a git config &#8211;global user.email &#8220;youremail@yourdomain.com&#8221; \u767b\u5f55\u540e\u590d\u5236 \u5c06\u201cyouremail@yourdomain.com\u201d\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002 \u6b65\u9aa4\u4e09\uff1a\u521b\u5efaGit\u4ed3\u5e93 \u8981\u4f7f\u7528Git\uff0c\u60a8\u9700\u8981\u9996\u5148\u521b\u5efa\u4e00\u4e2aGit\u4ed3\u5e93\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u4f7f\u7528GUI\u5de5\u5177\u5b8c\u6210\u3002\u4ee5\u4e0b\u662f\u7528\u547d\u4ee4\u884c\u521b\u5efaGit\u4ed3\u5e93\u7684\u793a\u4f8b\uff1a mkdir myproject cd myproject git init \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u547d\u4ee4\u5c06\u5728\u60a8\u7684\u4e3b\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyproject\u201d\u7684\u76ee\u5f55\uff0c\u5e76\u5728\u5176\u4e2d\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\u3002 \u6b65\u9aa4\u56db\uff1a\u6dfb\u52a0\u6587\u4ef6 \u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230Git\u4ed3\u5e93\u4e2d\u3002\u8981\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230Git\u4ed3\u5e93\u4e2d\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a git add filename \u767b\u5f55\u540e\u590d\u5236 \u60a8\u53ef\u4ee5\u5c06\u201cfilename\u201d\u66ff\u6362\u4e3a\u60a8\u8981\u6dfb\u52a0\u7684\u5b9e\u9645\u6587\u4ef6\u540d\u3002\u5982\u679c\u8981\u5c06\u6240\u6709\u6587\u4ef6\u6dfb\u52a0\u5230Git\u4ed3\u5e93\u4e2d\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a git add . \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4\u4e94\uff1a\u63d0\u4ea4\u66f4\u6539 \u5f53\u60a8\u5bf9\u6587\u4ef6\u8fdb\u884c\u66f4\u6539\u540e\uff0c\u9700\u8981\u5c06\u66f4\u6539\u63d0\u4ea4\u5230Git\u4ed3\u5e93\u4e2d\u3002\u8981\u63d0\u4ea4\u66f4\u6539\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-19142","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19142","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=19142"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19142\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}