Github上傳代碼菜鳥超詳細教程【轉】


最近需要將課設代碼上傳到Github上,之前只是用來fork別人的代碼。

這篇文章寫得是windows下的使用方法。

第一步:創建Github新賬戶

第二步:新建倉庫

newgithub

第三部:填寫名稱,簡介(可選),勾選Initialize this repository with a README選項,這是自動創建REAMDE.md文件,省的你再創建。

createdemo

第四步:安裝Github shell程序,地址:http://windows.github.com/

第五步:打開Git Shell,輸入以下命令生成密鑰來驗證身份

ssh-keygen -C 'your@email.address' -t rsa

連續三個回車之后會在windows當前用戶目錄下生成.ssh文件夾,和linux一樣。

ssh3

把文件夾下的id_rsa.pub文件內容全部復制。

然后打開github賬戶設置,如圖

setting

打開ssh keys

ssh
右上角點擊add ssh key

ssh2

然后在title隨便輸入,key欄粘貼剛才的密鑰。

第六步:在Git Shell下輸入命令測試剛才的公鑰是否認證正確。

ssh -T git@github.com

正確結果會顯示:

Warning:Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
  Hi Flowerowl! You've successfully authenticated, but GitHub does not provide shell access.

warning 不用理會。

第七步:clone剛才新建的repository 到本地,輸入命令:

link

 git clone https://github.com/Flowerowl/stumansys.git

這時會在目錄下生成:

desk

第八步:將想上傳的代碼目錄拷貝到此文件夾下:

code

第九步:切換到Git shell 命令行下,輸入命令:

git init
git commit -m 'stumansys'
git remote add origin https://github.com/Flowerowl/stumansys.git
git push origin master

如果執行git remote add origin

https://github.com/Flowerowl/stumansys.git

,出現錯誤:

  fatal: remote origin already exists

則執行以下語句:

  git remote rm origin

再往后執行git remote add origin https://github.com/Flowerowl/stumansys.git 即可。

在執行git push origin master時,報錯:

  error:failed to push som refs to.......

則執行以下語句:

  git pull origin master

先把遠程服務器github上面的文件拉先來,再push 上去。

cmd

最后,你可以去項目頁面查看了~~代碼上傳成功!

有問題可以在下方留言,大家一起解決~

轉載請注明:吉吉於 » Github上傳代碼菜鳥超詳細教程


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM