{"id":755,"date":"2018-04-04T15:10:58","date_gmt":"2018-04-04T07:10:58","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=755"},"modified":"2018-04-04T15:10:58","modified_gmt":"2018-04-04T07:10:58","slug":"%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87git%e5%b0%86%e6%9c%ac%e5%9c%b0%e9%a1%b9%e7%9b%ae%e6%8f%90%e4%ba%a4%e5%88%b0%e7%a0%81%e4%ba%91%e6%88%96github","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=755","title":{"rendered":"\u5982\u4f55\u901a\u8fc7Git\u5c06\u672c\u5730\u9879\u76ee\u63d0\u4ea4\u5230\u7801\u4e91\u6216GitHub"},"content":{"rendered":"<p><strong>\u4f55\u4e3a\u7801\u4e91\uff1f<\/strong><\/p>\n<p>\u7801\u4e91\u662f\u4e13\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u7a33\u5b9a\u3001\u9ad8\u6548\u3001\u5b89\u5168\u7684\u4e91\u7aef\u8f6f\u4ef6\u5f00\u53d1\u534f\u4f5c\u5e73\u53f0\u3002<br \/>\n\u65e0\u8bba\u662f\u4e2a\u4eba\u3001\u56e2\u961f\u3001\u6216\u662f\u4f01\u4e1a\uff0c\u90fd\u80fd\u591f\u7528\u7801\u4e91\u5b9e\u73b0\u4ee3\u7801\u6258\u7ba1\u3001\u9879\u76ee\u7ba1\u7406\u3001\u534f\u4f5c\u5f00\u53d1\u3002<\/p>\n<p><strong>PS\uff1a<\/strong><\/p>\n<p>\u8bf4\u767d\u4e86\u5c31\u662f\u548cGithub\u4e00\u6837\u3002\u4f46\u6ca1\u6709Github\u7684\u5f00\u53d1\u8005\u548c\u9879\u76ee\u591a\uff0c\u518d\u600e\u4e48\u8bf4\uff0c\u4eba\u5bb6\u662f\u5168\u7403\u6027\u7684\u3002<br \/>\n\u4f46\u7801\u4e91\u901f\u5ea6\u5feb\uff08\u6bd5\u7adf\u5728\u56fd\u5185\uff09\uff0c\u79c1\u6709\u4ed3\u5e93\u514d\u8d39\uff0c\u800c\u4e14\u4e0d\u9650\u5236\u79c1\u6709\u5e93\u548c\u516c\u6709\u5e93\u6570\u91cf\uff0c\u53ef\u4ee5\u4f5c\u4e3a\u5907\u4efd\u4ed3\u5e93\u3002<\/p>\n<p>OS\u73af\u5883\uff1a<code>CentOS Linux release 7.4.1708 (Core)<\/code><\/p>\n<p><strong>1.\u5b89\u88c5\u914d\u7f6eGit<\/strong><\/p>\n<pre>$ yum install git -y\n$ git config --global user.name \"renwole\"\n$ git config --global user.email renwole@renwole.com<\/pre>\n<p><strong>2.\u5728\u7ec8\u7aef\u751f\u6210ssh\u516c\u94a5<\/strong><\/p>\n<p>\u6267\u884c\u4e0b\u9762\u547d\u4ee4\uff0c\u4e09\u6b21\u56de\u8f66\u5373\u53ef\u751f\u6210\u00a0<code>ssh key<\/code>\uff1a<\/p>\n<pre>$ ssh-keygen -t rsa -C \"renwole@renwole.com\"<\/pre>\n<p><strong>3.\u67e5\u770b\u751f\u6210\u7684public key<\/strong><\/p>\n<pre>$ cat ~\/.ssh\/id_rsa.pub\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDR9k1FgZRJN3P7V9tLfWZQ......<\/pre>\n<p>\u5c06\u4ee5\u4e0a\u6253\u5370\u51fa\u5c4f\u5e55\u7684\u5185\u5bb9\u6dfb\u52a0\u5230\u7801\u4e91\u3002<\/p>\n<p>\u8bf4\u660e\uff1a<code>SSH key<\/code>\u6dfb\u52a0\u5730\u5740:<code>https:\/\/gitee.com\/profile\/sshkeys<\/code>\u3002\u516c\u94a5\u6807\u9898\u4efb\u610f\u3002<\/p>\n<p><strong>4.\u6d4b\u8bd5\u662f\u5426\u53ef\u4ee5\u4fe1\u4efb\u8fde\u63a5<\/strong><\/p>\n<p>\u6dfb\u52a0\u540e\uff0c\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ ssh -T git@gitee.com\nThe authenticity of host 'gitee.com (120.55.226.24)' can't be established.\nECDSA key fingerprint is SHA256:FQGC9Kn\/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.\nECDSA key fingerprint is MD5:27:e5:d3:79:2a:9e:eb:6c:93:cd:1f:c1:47:a3:54:b1.\nAre you sure you want to continue connecting (yes\/no)? yes<strong>\u3010\u8f93\u5165yes\u56de\u8f66\u3011<\/strong>\nWarning: Permanently added 'gitee.com,120.55.226.24' (ECDSA) to the list of known hosts.\nAuthentication failed.<\/pre>\n<p>\u518d\u6b21\u6267\u884c\uff1a<\/p>\n<pre>$ ssh -T git@gitee.com\nWelcome to Gitee.com, yourname!<\/pre>\n<p>\u8fd4\u56de\u4fe1\u606f\u8868\u793a\u5df2\u7ecf\u6210\u529f\u3002<\/p>\n<p><strong>5.\u5728\u7801\u4e91\u521b\u5efa\u79c1\u6709\u4ed3\u5e93<\/strong><\/p>\n<p>\u6253\u5f00\u7801\u4e91\u9996\u9875 \u2013 \u767b\u5f55 \u2013 \u70b9\u51fb\u53f3\u4e0a\u89d2\u5706\u5f62+\u53f7 \u2013 \u586b\u5199\u4f60\u7684\u9879\u76ee\u4fe1\u606f \u2013 \u521b\u5efa\u5b8c\u6210\u3002<\/p>\n<p>\u6253\u5f00\u4f60\u7684\u9879\u76ee\u5730\u5740\uff0c\u4f8b\u5982\uff1a<\/p>\n<p><code>https:\/\/gitee.com\/renwole\/renwolecom<\/code><\/p>\n<p>\u70b9\u51fb\u514b\u9686\/\u4e0b\u8f7d \u2013 \u83b7\u53d6\u4f60\u7684SSH\u5730\u5740\uff0c\u4e0b\u9762\u8981\u7528\u5230\u3002<\/p>\n<p><strong>6.\u628a\u8fdc\u7a0b\u4ed3\u5e93\u9879\u76eeclone\u5230\u672c\u5730<\/strong><\/p>\n<pre>$ cd \/mnt\n$ git clone git@gitee.com:renwole\/renwolecom.git\nCloning into 'renwolecom'...\nremote: Counting objects: 11, done.\nremote: Compressing objects: 100% (10\/10), done.\nremote: Total 11 (delta 2), reused 0 (delta 0)\nReceiving objects: 100% (11\/11), 19.51 MiB | 5.46 MiB\/s, done.\nResolving deltas: 100% (2\/2), done.<\/pre>\n<pre>$ cd renwolecom\n$ ll\ntotal 16\n-rw-r--r--. 1 root root 10254 Nov 22 09:26 LICENSE\n-rw-r--r--. 1 root root    13 Nov 22 09:26 README.md<\/pre>\n<p>\u5df2\u7ecf\u6210\u529f\u514b\u9686\u5230\u672c\u5730\u3002<\/p>\n<p><strong>7.\u63d0\u4ea4\u9879\u76ee<\/strong><\/p>\n<p>\u4f60\u53ef\u4ee5\u5c06<code>renwolecom<\/code>\u76ee\u5f55\u89c6\u4e3a\u4f60\u7684\u9879\u76ee\uff0c\u9c81\u5b8c\u4ee3\u7801\u76f4\u63a5\u63d0\u4ea4\u3002<\/p>\n<p>\u65e0\u8bba\u6b64\u9879\u76ee\u662f\u5426\u591a\u4eba\u53c2\u4e0e\uff0c<code>push<\/code>\u4e4b\u524d\u5148<code>pull<\/code>\uff0c\u770b\u662f\u5426\u6709<code>merge<\/code>\u4ee3\u7801\uff0c\u82e5\u5b58\u5728<code>merge<\/code>\u5c31\u89e3\u51b3<code>merge<\/code>\uff0c\u82e5\u65e0\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git pull origin master\n$ git add -A\n$ git commit -m 'init'\n$ git push origin master<\/pre>\n<p><strong>8.\u5220\u9664GIT\u4ed3\u5e93\u6240\u6709\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55<\/strong><\/p>\n<pre>8.1.Checkout\n\n$ git checkout --orphan latest_branch\n\n8.2. Add all the files\n\n$ git add -A\n\n8.3. Commit the changes\n\n$ git commit -am \"commit message\"\n\n8.4. Delete the branch\n\n$ git branch -D master\n\n8.5.Rename the current branch to master\n\n$ git branch -m master\n\n8.6.Finally, force update your repository\n\n$ git push -f origin master<\/pre>\n<p>\u5220\u9664\u8fdc\u7a0b\u6587\u4ef6\uff0c\u672c\u5730\u4fdd\u7559\uff1a<\/p>\n<pre>$ git rm --cached \u6587\u4ef6\u540d\n$ git commit -m \"remove file from remote repository\"\n$ git push<\/pre>\n<p>\u5220\u9664\u8fdc\u7a0b\u6587\u4ef6\u5939\uff0c\u672c\u5730\u4fdd\u7559\uff1a<\/p>\n<pre>$ git rm --cached -r \u6587\u4ef6\u5939\u540d\n$ git commit -m \"remove directory from remote repository\"\n$ git push<\/pre>\n<p>\u6ce8\u610f\uff1a\u5220\u9664\u6587\u4ef6\u5939\u8bf7\u4f7f\u7528 -r \u53c2\u6570\u3002<\/p>\n<p>\u8bf4\u660e\uff1a\u6700\u540e\u4e0a\u4f20\u9879\u76ee\u65f6\u53ef\u9009\u53c2\u6570\u00a0<code>git push origin master -f<\/code>\u00a0\u8868\u793a\u5f3a\u5236\u63a8\u9001\u8981\u4e0a\u4f20\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u6267\u884c\u7ed3\u675f\u540e\uff0c\u53ef\u4ee5\u5237\u65b0\u9879\u76ee\u5730\u5740\u5e76\u67e5\u770b\u4ece\u672c\u5730<code>push<\/code>\u4ed3\u5e93\u7684\u5185\u5bb9\u3002<\/p>\n<p><strong>\u7248\u6743\u58f0\u660e\uff1a<\/strong>\u672c\u7ad9\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u4efb\u4f55\u5f62\u5f0f\u7684\u8f6c\u8f7d\u3002<br \/>\n<strong>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<\/strong><a href=\"https:\/\/renwole.com\/archives\/866\">\u5982\u4f55\u901a\u8fc7Git\u5c06\u672c\u5730\u9879\u76ee\u63d0\u4ea4\u5230\u7801\u4e91\u6216GitHub | \u4efb\u6211\u4e50<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f55\u4e3a\u7801\u4e91\uff1f \u7801\u4e91\u662f\u4e13\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u7a33\u5b9a\u3001\u9ad8\u6548\u3001\u5b89\u5168\u7684\u4e91\u7aef\u8f6f\u4ef6\u5f00\u53d1\u534f\u4f5c\u5e73\u53f0\u3002 \u65e0\u8bba\u662f\u4e2a\u4eba\u3001\u56e2\u961f\u3001\u6216\u662f\u4f01\u4e1a\uff0c\u90fd\u80fd\u591f\u7528\u7801\u4e91\u5b9e\u73b0\u4ee3\u7801\u6258\u7ba1\u3001\u9879\u76ee\u7ba1\u7406\u3001\u534f\u4f5c\u5f00\u53d1\u3002 PS\uff1a \u8bf4\u767d\u4e86\u5c31\u662f\u548cGithub\u4e00\u6837\u3002\u4f46\u6ca1\u6709Github\u7684\u5f00\u53d1\u8005\u548c\u9879\u76ee\u591a\uff0c\u518d\u600e\u4e48\u8bf4\uff0c\u4eba\u5bb6\u662f\u5168\u7403\u6027\u7684\u3002 \u4f46\u7801\u4e91\u901f\u5ea6\u5feb\uff08\u6bd5\u7adf\u5728\u56fd\u5185\uff09\uff0c\u79c1\u6709\u4ed3\u5e93\u514d\u8d39\uff0c\u800c\u4e14\u4e0d\u9650\u5236\u79c1\u6709\u5e93\u548c\u516c\u6709\u5e93\u6570\u91cf\uff0c\u53ef\u4ee5\u4f5c\u4e3a\u5907\u4efd\u4ed3\u5e93\u3002 OS\u73af\u5883\uff1aCentOS Linux release 7.4.1708 (Core) 1.\u5b89\u88c5\u914d\u7f6eGit $ yum install git -y $ git config [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-755","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=755"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/755\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}