{"id":5428,"date":"2016-10-09T10:05:49","date_gmt":"2016-10-09T02:05:49","guid":{"rendered":"https:\/\/sdeno.com\/?p=5428"},"modified":"2019-10-11T18:12:48","modified_gmt":"2019-10-11T10:12:48","slug":"ubuntu%e4%b8%8b%e4%bd%bf%e7%94%a8git%e4%b8%8a%e4%bc%a0%e9%a1%b9%e7%9b%ae%e5%88%b0github%e4%b8%ad","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=5428","title":{"rendered":"ubuntu\u4e0b\u4f7f\u7528git\u4e0a\u4f20\u9879\u76ee\u5230github\u4e2d"},"content":{"rendered":"<p>\u8981\u5728ubuntu\u73af\u5883\u91cc\u4f7f\u7528git\u4e0a\u4f20\u9879\u76ee\u5230github\uff0c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1\uff0c\u662f\u5426\u5b89\u88c5git<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 git &#8211;version \u6d4b\u8bd5\u662f\u5426\u5b89\u88c5<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u4f7f\u7528\u547d\u4ee4\uff1a sudo apt-get install git git-core \u5b89\u88c5git<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2\uff0c\u83b7\u53d6\u00a0ssh\u5bc6\u94a5<\/strong><\/p>\n<pre>ssh-keygen -C \"\u4f60\u7684github\u90ae\u7bb1\" -f ~\/.ssh\/github\r\n\u5982\u679c\u6267\u884c\u7684\u8fc7\u7a0b\u4e2d\uff0c\u63d0\u793a\u4f60\u8bbe\u7f6e\u5bc6\u7801\uff0c\u8fd9\u4e9b\u90fd\u4e0d\u7ba1\u4e00\u8def\u56de\u8f66\u4e0b\u53bb\u3002<\/pre>\n<p>\u8fd9\u65f6\u5019\u4f1a\u5728\u7684\u4f60~\/\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a.ssh\/\u76ee\u5f55\uff0c\u5982\u679c\u4e0d\u77e5\u9053~\/\u76ee\u5f55\u662f\u4ec0\u4e48\u8f93\u5165pwd\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0bubuntu\u4f1a\u628a.ssh\/\u9690\u85cf\u8d77\u6765\u3002<br \/>\n\u67e5\u770b.ssh\u76ee\u5f55\u4e0b\u7684github.pub\u83b7\u53d6\u5230\u516c\u94a5\u8ba4\u8bc1\uff0c\u5c31\u662f\u4e00\u4e32\u4e71\u7801\u3002<\/p>\n<pre>~$ cd .ssh\r\n~\/.ssh$ sudo gedit github.pub  \/\/\u5bc6\u94a5\u5c31\u5728\u6b64\u6587\u4ef6<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5982\u679c\u63d0\u793a\uff1a<\/p>\n<pre>Permission denied (publickey).\r\nfatal: Could not read from remote repository.<\/pre>\n<p>\u8fd8\u6709\u53e6\u4e00\u4e2a\u65b9\u6cd5\u83b7\u53d6ssh:<\/p>\n<p>\u6267\u884c<\/p>\n<pre>ssh-keygen -t rsa<\/pre>\n<p>\u4e4b\u540e\u4e00\u8def\u56de\u8f66<\/p>\n<p>\u540c\u6837\u53bb\u5230~\/.ssh\u76ee\u5f55\u4e0b\u628a\u6587\u4ef6id.rsa.pub\u91cc\u9762\u7684\u5bc6\u94a5\u7c98\u8d34\u5230github\u4e2d\uff0c\u5373\u53ef<\/p>\n<p>\u5982\u679c\u6d89\u53ca\u5230\u540c\u65f6\u4f7f\u7528github\u548cgitlab\uff0c\u53c2\u8003\u300a<a href=\"https:\/\/sdeno.com\/?p=7715\" target=\"_blank\" rel=\"noopener\">Git\u591aSSH Key\u5171\u5b58\u95ee\u9898<\/a>\u300b<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3\uff0c\u5bc6\u94a5\u8ba4\u8bc1<\/strong><\/p>\n<p>\u767b\u5f55\u6211\u4eec\u7684github&#8211;\u70b9\u51fb\u5934\u50cf\u53f3\u8fb9\u4e0b\u62c9\u5c0f\u4e09\u89d2&#8211;\u70b9\u51fb&#8221;settings&#8221;&#8211;\u70b9\u51fb\u5de6\u4fa7\u680f&#8221;SSH and GPG keys&#8221;&#8211;\u7136\u540e\u5728\u53f3\u4fa7\u680f\u70b9\u51fb&#8221;New SSH key&#8221;<\/p>\n<p>title\u680f\u968f\u4fbf\u8f93\u5165\uff0ckey\u680f\u7c98\u8d34\u521a\u521a\u83b7\u53d6\u5230\u7684\u5bc6\u94a5\uff0c\u6700\u540e\u70b9\u51fb&#8221;Add SSH key&#8221;\u5c31\u884c<\/p>\n<a href=\"https:\/\/sdeno.com\/?attachment_id=5430\" rel=\"attachment wp-att-5430\"><figure class=\"mdx-lazyload-container\" style=\"max-width:496px\"><div style=\"padding-top:93.75%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"496\" height=\"465\" class=\"alignnone size-full wp-image-5430 lazyload\" title=\"github2\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/10\/github2.jpg\" alt=\"github2\"><\/figure><\/a>\n<p>&nbsp;<\/p>\n<p><strong>4\uff0c\u521b\u5efagit\u4ed3\u5e93<\/strong><\/p>\n<a href=\"https:\/\/sdeno.com\/?attachment_id=5431\" rel=\"attachment wp-att-5431\"><figure class=\"mdx-lazyload-container\" style=\"max-width:257px\"><div style=\"padding-top:60.700389105058%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"257\" height=\"156\" class=\"alignnone size-full wp-image-5431 lazyload\" title=\"github3\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/10\/github3.jpg\" alt=\"github3\"><\/figure><\/a>\n<a href=\"https:\/\/sdeno.com\/?attachment_id=5432\" rel=\"attachment wp-att-5432\"><figure class=\"mdx-lazyload-container\" style=\"max-width:457px\"><div style=\"padding-top:128.00875273523%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"457\" height=\"585\" class=\"alignnone size-full wp-image-5432 lazyload\" title=\"github4\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/10\/github4.jpg\" alt=\"github4\"><\/figure><\/a>\n<p>&nbsp;<\/p>\n<p><strong>5\uff0c\u672c\u5730\u521b\u5efa\u9879\u76ee\u6587\u4ef6<\/strong><\/p>\n<p>\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\u4e13\u95e8\u8d1f\u8d23\u9879\u76ee\u7684\u4e0a\u4f20\u548c\u66f4\u65b0\uff0c\u8fdb\u5165\u5230\u6587\u4ef6\u5939\u4e2d\uff0c\u5148\u628a\u521a\u521a\u521b\u5efa\u597d\u7684git\u4ed3\u5e93\u62d6\u8fdb\u672c\u5730<\/p>\n<pre>git clone git@github.com:chen77134056\/express_blog.git\r\n\/\/\u4f1a\u63d0\u793a\u4f60\u8f93\u5165github\u7684\u5e10\u53f7\u548c\u5bc6\u7801<\/pre>\n<p>git\u7684\u5730\u5740\u83b7\u53d6\u8fdb\u5165\u5230\u521a\u521a\u521b\u5efa\u7684git\u4ed3\u5e93\u91cc<\/p>\n<a href=\"https:\/\/sdeno.com\/?attachment_id=5433\" rel=\"attachment wp-att-5433\"><figure class=\"mdx-lazyload-container\" style=\"max-width:435px\"><div style=\"padding-top:47.126436781609%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"435\" height=\"205\" class=\"alignnone size-full wp-image-5433 lazyload\" title=\"github5\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/10\/github5.jpg\" alt=\"github5\"><\/figure><\/a>\n<p>&nbsp;<\/p>\n<p>\u4e4b\u540e\u4f1a\u53d1\u73b0\u591a\u51fa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u591a\u51fa\u7684\u6587\u4ef6\u5939\u547d\u540d\u5c31\u662f\u6211\u4eec\u7684\u4ed3\u5e93\u540d\u79f0\uff0c\u5c31\u662f\u6211\u4eec\u7684git\u76ee\u5f55\u4e86\uff0c\u4ee5\u540e\u6709\u4ec0\u4e48\u9700\u8981\u4e0a\u4f20\u7684\u5c31\u653e\u5728\u521a\u521a\u90a3\u4e2a\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<p>\u4e4b\u540e\u6309\u6b65\u9aa4\u8f93\u5165\u4ee5\u4e0b<\/p>\n<pre>git add . \/\/ \u66f4\u65b0\u6574\u4e2a\u76ee\u5f55\r\ngit config user.name \"chen77134056\" \/\/\u7b2c\u4e00\u6b21\u9700\u8981\u914d\u7f6e\r\ngit config user.email \"xxxx@xx.com\" \/\/\u7b2c\u4e00\u6b21\u9700\u8981\u914d\u7f6e\r\ngit commit -m \"\u66f4\u65b0\u7248\u672c\u7b80\u8981\u8bf4\u660e\"\r\ngit push -u origin master<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5982\u679c\u8981\u4e0a\u4f20\u6587\u4ef6\u5c31\u628a\u6587\u4ef6\u590d\u5236\u5230\u6211\u4eec\u7684\u4ed3\u5e93\u76ee\u5f55\u4e2d\uff0c\u5728\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<pre>git add . \/\/ \u66f4\u65b0\u6574\u4e2a\u76ee\u5f55\r\ngit commit -m \"\u66f4\u65b0\u7248\u672c\u7b80\u8981\u8bf4\u660e\"\r\ngit push -u origin master<\/pre>\n<p>\u5c31\u80fd\u4e0a\u4f20\u6211\u4eec\u7684\u9879\u76ee\u4e86\uff0c\u4e4b\u540e\u5728\u53bb\u8bbf\u95ee\u6211\u4eec\u521a\u521a\u5728github\u4e2d\u7684\u521a\u521a\u521b\u5efa\u7684\u4ed3\u5e93\u5c31\u4f1a\u53d1\u73b0\u6709\u6587\u4ef6\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u5728ubuntu\u73af\u5883\u91cc\u4f7f\u7528git\u4e0a\u4f20\u9879\u76ee\u5230github\uff0c\u6b65\u9aa4\u5982\u4e0b\uff1a &nbsp; 1\uff0c\u662f\u5426\u5b89\u88c5git \u53ef\u4ee5\u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-5428","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5428"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5428\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}