如何配置git ssh连接,如何在GitHub上添加协作开发者,如何配置gitignore和如何在GitHub上删除资源库.

来源:互联网 发布:网络票和窗口票比例 编辑:程序博客网 时间:2024/06/12 01:27
**********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文件中的内容按照如下图片添加到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.参考http://stackoverflow.com/questions/11041729/why-does-github-recommend-https-vs-ssh**********2.添加协作开发者.按照git如下图片添加协作开发者.


注意:协作开发者也要有自己的GitHub账户,本地的GitHub工作空间.协作开发者通过指令将管理员的项目clone一份,clone的url是管理员GitHub上的项目url.这样协作开发者就可以在自己的工作空间对项目进行各种操作了.除了上面的合作方式,还有一种合作方式:通过fork和pull request.按照如下图片将管理员的项目fork一下,即将管理员的项目打一个分支到自己的GitHub上



然后将自己GitHub上的项目clone一份到本地的工作空间,这样就可以对项目进行各种操作了,这里的操作不会影响到管理员GitHub上的项目.如果有一天自己的任务完成了,可以通过发一个pull request与管理员分享,如果管理员认为没有问题,可以进行merge,如果觉得有问题,可以进行讨论.参考http://tech.marsw.tw/blog/2013/08/17/git-notes-github-n-person-cooperation-settings/**********3.忽略某些文件提交.通过如下指令,在git资源库目录下生成.gitnore文件.iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master)$ touch .gitignore然后在.gitnore目录下配置忽略的文件,如下:message-web/test/*message-web/target/*message-web/bin/*message-web/src/main/resources/message.properties忽略某些文件提交的目的有两个:1.对于一些二进制数据没有必要进行提交.2.对于一些敏感信息,例如数据库连接信息等不能进行提交.**********4.在GitHub上删除资源库.



1 0