上傳本地文件到github
第一步:創建新的倉庫
勾選Initialize this repository with a README選項,自動創建REAMDE.md文件。
第二步:
$ git config --global user.name "hanyuntao"
$ git config --global user.email "[email protected]"
第三步:生成ssh key
首先檢查是否已生成密鑰cd ~/.ssh
,如果返回的ls
有3個文件,則密鑰已經生成。
如果沒有密鑰,通過
$ ssh-keygen -t rsa -C "[email protected]"
生成,生成過程中一路按3次回車鍵就好了。
生成成功後,去對應目錄找到id_rsa.pub用記事本打開,得到ssh key公鑰。
第四步:為github賬號配置ssh 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 不用理會。
第六步:切換到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
如果仍然不成功
git remote set-url origin [email protected]:username/repository
上傳過程中大概遇到這些問題。
上傳本地文件到github