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

轉載註明:於哲的博客 Github上傳代碼菜鳥超詳細教程


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

第一步:創建Github新賬戶

第二步:新建倉庫

newgithub

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

createdemo

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

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

ssh-keygen -C '[email protected]' -t rsa

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

ssh3

把文件夾下的id_rsa.pub文件內容全部複製。

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

setting

打開ssh keys

ssh
右上角點擊add ssh key

ssh2

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

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

ssh -T [email protected]

正確結果會顯示:

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上傳代碼菜鳥超詳細教程


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章