系统大全为您提供1.GIT是什么?Git是一个分布式版本控制/软件配置管理软件,原是Linux内核开发者LinusTorvalds为更好地管理Linux内核开发而设计。相比CVS/SVN,Git的优势:-支持离线开发,离线Repository-强大的分支功能,适合多个独立开发者协作-速度块2.GITHUB是什么?GitHub是一个共享虚拟主机服务,用于存放使用Git版本控制的软件代码和内容项目。3.Linux虚拟机上使用git和github3.1注册github账号此步骤比较简单,无需赘述。3.2虚拟机安装git客户端我使用的是CentOS虚拟机,安装命令如下:yuminstallgitgit-gui3.3生成秘钥对,这样项目可以push到github上[root@CentOStuzhutuzhu]#ssh-keygen-trsa-C"*****@**.com"Generatingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):Enterpassphrase(emptyfornopassphrase):Entersamepassphraseagain:Youridentificationhasbeensavedin/root/.ssh/id_rsa.Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.Thekeyfingerprintis:63:68:68:ad:23:0f:8f:85:4a:cc:67:60:47:9e:7a:fa15895214140@126.comThekey'srandomartimageis:+--[RSA2048]----+|||||.||o.o.||o+o+S||++oo..||=+++||..=B.||..oEo|+-----------------+[root@CentOStuzhutuzhu]#3.4将.ssh/id_rsa.oub拷贝到GitHub 3.5 测试是否能连接到GitHub[root@CentOS tuzhutuzhu]# ssh git@github.comThe authenticity of host 'github.com (192.30.252.131)' can't be established.RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.Are you sure you want to continue connecting (yes)? yesWarning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of kNown hosts.Enter passphrase for key '/root/.ssh/id_rsa':Permission denied (publickey).[root@CentOS tuzhutuzhu]#3.6 设置Git全局用户配置# git config --global user.name "Firstname Lastname"# git config --global user.email "your_email@youremail.com"此处用户名为自己的实际姓名(自定义的),而非登录用户名3.7 Git创建一个库(Create a Repository) 创建完成:3.8创建本地新项目仓库,此步骤可按照上图GitHub中仓库创建完成后网页上的提示执行#mkdirnew-project(*1)#cdnew-project#gitinit#touchREADME#gitaddREADME#gitcommit-m'firstcommit'定义远程服务器别名origin#gitremoteaddorigingit@github.com:***/new-project.git(*2)本地和远程合并,本地默认分支为master#gitpushoriginmaster(*1)此处的仓库名必须与3.7中在GitHub中创建的仓库名相同(*2)此处***就是GitHub的用户名在执行push操作时,可能会出现如下错误:[root@CentOSvmware]#gitpush-uoriginmastererror:TherequestedURLreturnederror:403whileaccessingfatal:/tuzhutuzhu/vmware.gitfetch=+refs/heads/*:refs/remotes/origin/*再次执行push操作,结果如下:[root@CentOSvmware]#gitpush-uoriginmasterEnterpassphraseforkey'/root/.ssh/id_rsa':Countingobjects:7,done.Deltacompressionusingupto2threads.Compressingobjects:100%(3/3),done.Writingobjects:100%(7/7),548bytes,done.Total7(delta0),reused0(delta0)Tossh://git@github.com/tuzhutuzhu/vmware.git*[newbranch]master->masterBranchmastersetuptotrackremotebranchmasterfromorigin.[root@CentOSvmware]#这样,就将文件上传到GitHub上了。 以上就是系统大全给大家介绍的如何使的方法都有一定的了解了吧,好了,如果大家还想了解更多的资讯,那就赶紧点击系统大全官网吧。 本文来自系统大全http:///如需转载请注明!推荐:win7纯净版