{"id":18956,"date":"2024-11-19T13:22:02","date_gmt":"2024-11-19T05:22:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18956\/"},"modified":"2024-11-19T13:22:02","modified_gmt":"2024-11-19T05:22:02","slug":"linux%e4%b8%8a%e6%80%8e%e4%b9%88%e6%90%ad%e5%bb%bagithub%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18956\/","title":{"rendered":"Linux\u4e0a\u600e\u4e48\u642d\u5efagithub\u670d\u52a1\u5668"},"content":{"rendered":"<p>github\u662f\u5168\u7403\u6700\u5927\u7684\u7a0b\u5e8f\u5458\u793e\u4ea4\u7f51\u7ad9\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u4e0a\u9762\u5171\u540c\u534f\u4f5c\u5f00\u5c55\u9879\u76ee\u3002\u4e3a\u4e86\u66f4\u597d\u5730\u534f\u4f5c\u548c\u7ba1\u7406\u4ee3\u7801\uff0c\u5f88\u591a\u7a0b\u5e8f\u5458\u9009\u62e9\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\u642d\u5efagithub\u670d\u52a1\u5668\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728linux\u670d\u52a1\u5668\u4e0a\u642d\u5efagithub\u670d\u52a1\u5668\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5Git<\/p>\n<p>\u5728Linux\u670d\u52a1\u5668\u4e0a\u642d\u5efaGitHub\u670d\u52a1\u5668\uff0c\u9996\u5148\u8981\u5b89\u88c5Git\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Git\uff1a<\/p>\n<pre>sudo apt-get install git-core<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5b89\u88c5\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1Git\u662f\u5426\u6210\u529f\u5b89\u88c5\uff1a<\/p>\n<pre>git --version<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u521b\u5efa\u7528\u6237<\/p>\n<p>\u4e3a\u4e86\u66f4\u597d\u5730\u7ba1\u7406\u4ee3\u7801\uff0c\u60a8\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u534f\u4f5c\u8005\u521b\u5efa\u4e00\u4e2a\u5355\u72ec\u7684\u7528\u6237\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u7528\u6237\uff1a<\/p>\n<pre>sudo adduser &lt;username&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2dusername\u662f\u60a8\u8981\u521b\u5efa\u7684\u7528\u6237\u540d\u3002\u7136\u540e\u8bbe\u7f6e\u7528\u6237\u5bc6\u7801\uff0c\u8ddf\u968f\u547d\u4ee4\u63d0\u793a\u5b8c\u6210\u8bbe\u7f6e\u5373\u53ef\u3002<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u521b\u5efaSSH\u5bc6\u94a5<\/p>\n<p>\u4e3a\u4e86\u786e\u4fdd\u5b89\u5168\u6027\u5e76\u5141\u8bb8\u534f\u4f5c\u8005\u63a8\u9001\u66f4\u6539\uff0c\u6211\u4eec\u9700\u8981\u5728\u6bcf\u4e2a\u7528\u6237\u4e0a\u8bbe\u7f6eSSH\u5bc6\u94a5\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728\u6bcf\u4e2a\u7528\u6237\u4e0a\u521b\u5efa\u4e00\u4e2aSSH\u5bc6\u94a5\u3002<\/p>\n<p>\u4ea7\u751f\u5bc6\u94a5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>ssh-keygen -t rsa -C \"&lt;email&gt;\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>email \u586b\u5199\u60a8\u7684\u90ae\u7bb1\u5730\u5740\u3002<\/p>\n<p>\u5c06\u5bc6\u94a5\u6dfb\u52a0\u81f3\u516c\u5171\u8bbf\u95ee\uff1a<\/p>\n<pre>cd \/home\/&lt;username&gt;\/.ssh\ncp id_rsa.pub authorized_keys\nchmod 700 ~\/.ssh\nchmod 600 ~\/.ssh\/*\nsudo chown -R &lt;username&gt;:&lt;username&gt; ~\/.ssh<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0chome\/  \u662f\u7528\u6237\u7684\u6587\u4ef6\u5939\u4f4d\u7f6e\u3002 <\/p>\n<p>\u7b2c\u56db\u6b65\uff1a\u521b\u5efa\u4ed3\u5e93<\/p>\n<p>\u5728\u60a8\u7684\u7528\u6237\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u76ee\u5f55\uff0c\u4e3a\u60a8\u7684\u65b0\u9879\u76ee\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b58\u50a8\u5e93\uff1a<\/p>\n<pre>mkdir \/home\/&lt;username&gt;\/&lt;project_name&gt;.git\ncd \/home\/&lt;username&gt;\/&lt;project_name&gt;.git\ngit init --bare<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\u66f4\u6539\u5b58\u50a8\u5e93\u7684\u6743\u9650\uff0c\u4ee5\u4fbf\u5176\u4ed6\u7528\u6237\u4e5f\u53ef\u4ee5\u8bbf\u95ee\u5b83\uff1a<\/p>\n<pre>sudo chown -R &lt;username&gt;:&lt;username&gt; \/home\/&lt;username&gt;\/&lt;project_name&gt;.git\nsudo chmod -R ug+rwX \/home\/&lt;username&gt;\/&lt;project_name&gt;.git<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u65f6\u60a8\u5df2\u7ecf\u6210\u529f\u5728\u670d\u52a1\u5668\u4e0a\u642d\u5efa\u4e86\u4e00\u4e2aGitHub\u670d\u52a1\u5668\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u8fdb\u884c\u514b\u9686\uff0c\u6dfb\u52a0\u66f4\u6539\u5e76\u5c06\u5b83\u4eec\u63a8\u9001\u56de\u670d\u52a1\u5668\uff1a<\/p>\n<pre>git clone &lt;username&gt;@&lt;serverip&gt;:&lt;\/home\/&lt;username&gt;\/&lt;project_name&gt;.git&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4fee\u6539\u5b8c\u4ee3\u7801\u540e\u53ef\u4ee5\u5c06\u4ee3\u7801\u63a8\u9001\u81f3git\u670d\u52a1\u5668:<\/p>\n<pre>git add .\ngit commit -m \"first commit code \"\ngit push origin master<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u662f\u5728Linux\u670d\u52a1\u5668\u4e0a\u642d\u5efaGitHub\u670d\u52a1\u5668\u7684\u4e00\u4e9b\u7b80\u5355\u4ecb\u7ecd\u3002\u5e0c\u671b\u80fd\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002\u60a8\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8fdb\u884c\u8c03\u6574\u548c\u6539\u8fdb\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLinux\u4e0a\u600e\u4e48\u642d\u5efagithub\u670d\u52a1\u5668\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>github\u662f\u5168\u7403\u6700\u5927\u7684\u7a0b\u5e8f\u5458\u793e\u4ea4\u7f51\u7ad9\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u4e0a\u9762\u5171\u540c\u534f\u4f5c\u5f00\u5c55\u9879\u76ee\u3002\u4e3a\u4e86\u66f4\u597d\u5730\u534f\u4f5c\u548c\u7ba1\u7406\u4ee3\u7801\uff0c\u5f88\u591a\u7a0b\u5e8f\u5458\u9009\u62e9\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\u642d\u5efagithub\u670d\u52a1\u5668\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728linux\u670d\u52a1\u5668\u4e0a\u642d\u5efagithub\u670d\u52a1\u5668\u3002 \u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5Git \u5728Linux\u670d\u52a1\u5668\u4e0a\u642d\u5efaGitHub\u670d\u52a1\u5668\uff0c\u9996\u5148\u8981\u5b89\u88c5Git\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Git\uff1a sudo apt-get install git-core \u767b\u5f55\u540e\u590d\u5236 \u5b89\u88c5\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1Git\u662f\u5426\u6210\u529f\u5b89\u88c5\uff1a git &#8211;version \u767b\u5f55\u540e\u590d\u5236 \u7b2c\u4e8c\u6b65\uff1a\u521b\u5efa\u7528\u6237 \u4e3a\u4e86\u66f4\u597d\u5730\u7ba1\u7406\u4ee3\u7801\uff0c\u60a8\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u534f\u4f5c\u8005\u521b\u5efa\u4e00\u4e2a\u5355\u72ec\u7684\u7528\u6237\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u7528\u6237\uff1a sudo adduser &lt;username&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2dusername\u662f\u60a8\u8981\u521b\u5efa\u7684\u7528\u6237\u540d\u3002\u7136\u540e\u8bbe\u7f6e\u7528\u6237\u5bc6\u7801\uff0c\u8ddf\u968f\u547d\u4ee4\u63d0\u793a\u5b8c\u6210\u8bbe\u7f6e\u5373\u53ef\u3002 \u7b2c\u4e09\u6b65\uff1a\u521b\u5efaSSH\u5bc6\u94a5 \u4e3a\u4e86\u786e\u4fdd\u5b89\u5168\u6027\u5e76\u5141\u8bb8\u534f\u4f5c\u8005\u63a8\u9001\u66f4\u6539\uff0c\u6211\u4eec\u9700\u8981\u5728\u6bcf\u4e2a\u7528\u6237\u4e0a\u8bbe\u7f6eSSH\u5bc6\u94a5\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728\u6bcf\u4e2a\u7528\u6237\u4e0a\u521b\u5efa\u4e00\u4e2aSSH\u5bc6\u94a5\u3002 \u4ea7\u751f\u5bc6\u94a5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a ssh-keygen -t rsa -C &#8220;&lt;email&gt;&#8221; \u767b\u5f55\u540e\u590d\u5236 email \u586b\u5199\u60a8\u7684\u90ae\u7bb1\u5730\u5740\u3002 \u5c06\u5bc6\u94a5\u6dfb\u52a0\u81f3\u516c\u5171\u8bbf\u95ee\uff1a cd \/home\/&lt;username&gt;\/.ssh cp id_rsa.pub authorized_keys chmod 700 ~\/.ssh chmod 600 ~\/.ssh\/* sudo chown -R &lt;username&gt;:&lt;username&gt; ~\/.ssh \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0chome\/ \u662f\u7528\u6237\u7684\u6587\u4ef6\u5939\u4f4d\u7f6e\u3002 \u7b2c\u56db\u6b65\uff1a\u521b\u5efa\u4ed3\u5e93 \u5728\u60a8\u7684\u7528\u6237\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u76ee\u5f55\uff0c\u4e3a\u60a8\u7684\u65b0\u9879\u76ee\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b58\u50a8\u5e93\uff1a mkdir \/home\/&lt;username&gt;\/&lt;project_name&gt;.git cd [&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-18956","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18956","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=18956"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18956\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}