![](https://img.51dongshi.com/20250105/wz/18528768652.jpg)
系統大全為您提供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純凈版