Git如何通过SSH连接github和如何添加协作开发者

</pre><pre name="code" class="java">**********1.在执行git push origin master指令时报如下错误:iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ git push origin masterUsername for 'https://github.com': IluckySiPassword for 'https://IluckySi@github.com':Counting objects: 178, done.Delta compression using up to 4 threads.Compressing objects: 100% (100/100), done.eWfrror: RPC failed; result=56, HTTP code = 200 KiB/satal: The remote end hung up unexpectedlyWriting objects: 100% (123/123), 5.30 MiB | 13.00 KiB/s, done.Total 123 (delta 49), reused 0 (delta 0)fatal: The remote end hung up unexpectedlyEverything up-to-date问题:eWfrror: RPC failed; result=56, HTTP code = 200 KiB/s经上网查询,原因是http.postbuffer值较小,对postBuffer进行修改.iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ git config –global http.postbuffer 24288000iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ git config –listcore.symlinks=falsecore.autocrlf=truecolor.diff=autocolor.status=autocolor.branch=autocolor.interactive=truepack.packsizelimit=2ghelp.format=htmlhttp.sslcainfo=/bin/curl-ca-bundle.crtsendemail.smtpserver=/bin/msmtp.exediff.astextplain.textconv=astextplainrebase.autosquash=trueuser.name=sidongxueuser.email=sidongxue@sohu.comhttp.postbuffer=24288000//修改后的http.postbuffercore.repositoryformatversion=0core.filemode=falsecore.bare=falsecore.logallrefupdates=truecore.symlinks=falsecore.ignorecase=truecore.hidedotfiles=dotGitOnlyremote.orgin.url=https://github.com/IluckySi/message.gitremote.orgin.fetch=+refs/heads/*:refs/remotes/orgin/*remote.origin.url=https://github.com/IluckySi/message.gitremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ git push origin masterUsername for 'https://github.com': IluckySiPassword for 'https://IluckySi@github.com':Counting objects: 178, done.Delta compression using up to 4 threads.Compressing objects: 100% (100/100), done.Writing objects: 100% (123/123), 5.30 MiB | 0 bytes/s, done.Total 123 (delta 49), reused 0 (delta 0)配置完后,继续执行git push origin master指令,依然有问题,再次上网进行查询,经网上建议可以将https方式改为ssh方式.登录Github发现reomte的url有三种连接方式:https,ssh和svn,git连接github默认使用https.iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ git remote set-url origin git@github.com:IluckySi/message.gitiluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ git push origin masterReceived disconnect from 192.30.252.129: 11: Bye Byefatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.修改完后,继续执行git push origin master指令,还是有问题,再次上网进行查询,原来通过ssh连接github需要通过key.iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ ssh-keygen -t rsa -C "1151262684@qq.com"Generating public/private rsa key pair.Enter file in which to save the key (/c/Users/zhangmengjiao/.ssh/id_rsa):/c/Users/zhangmengjiao/.ssh/id_rsa already exists.Overwrite (y/n)? yEnter passphrase (empty for no passphrase): 输入github密码Enter same passphrase again:输入github密码Your identification has been saved in /c/Users/zhangmengjiao/.ssh/id_rsa.Your public key has been saved in /c/Users/zhangmengjiao/.ssh/id_rsa.pub.The key fingerprint is:ce:eb:cd:8e:5e:80:e9:3b:d6:f8:c2:75:63:d2:28:0d 1151262684@qq.comThe key's randomart image is:+–[ RSA 2048]—-+|||||||Eo||ooSo||..o=.=||..=o+..||*..*||..**.+|+—————–+iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)生成key后,在/c/Users/用户/目录下会生成一个.ssh目录,将.ssh目录下id_rsa.pub文件中的内容按照git整理2-1图片添加到github中,添加完成后,再次执行指令,ok,成功了!$ git push origin masterEnter passphrase for key '/c/Users/zhangmengjiao/.ssh/id_rsa':Counting objects: 178, done.Delta compression using up to 4 threads.Compressing objects: 100% (100/100), done.Writing objects: 100% (123/123), 5.30 MiB | 44.00 KiB/s, done.Total 123 (delta 49), reused 0 (delta 0)To git@github.com:IluckySi/message.git 8dae8c8..f6dc5b2 master -> masteriluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$??????????问题:https,ssh和svn的区别?官方建议使用https.参考**********2.添加协作开发者.按照git整理2-2图片添加协作开发者.注意:协作开发者也要有自己的GitHub账户,本地的GitHub工作空间.协作协作开发者通过指令将管理员的项目clone一份,clone的url是管理员的项目url.这样协作开发者就可以在自己的工作空间对项目进行各种操作了.除了上面的合作方式,还有一种合作方式:通过fork和pull request.按照git整理2-3图片将管理员的项目fork一下,即将管理员的项目打一个分支到自己的GitHub上,然后将自己GitHub上的项目clone一份到本地的工作空间,这样就可以对项目进行各种操作了,这里的操作不会影响到管理员GitHub上的项目.如果有一天自己的任务完成了,可以通过发一个pull request与管理员分享,如果管理员认为没有问题,可以进行merge,如果觉得有问题,可以进行讨论.参考

,是清晰的又是朦胧的,是一杯苦茶,最后却品出清雅之香。

Git如何通过SSH连接github和如何添加协作开发者

相关文章:

你感兴趣的文章:

标签云: