本地倉庫使用如下命令初始化:
$ git init
之后使用如下命令添加遠程庫:
$ git remote add origin git@github.com:hahah/ftpmanage.git
然后使用
$ git push -u origin master
出現(xiàn)如下錯誤:
error: src refspec master does not match any. error: failed to push some refs to 'git@github.com:hahaha/ftpmanage.git'
引起該錯誤的原因是,目錄中沒有文件,空目錄是不能提交上去的
解決方法:
touch README
git add README
git commit -m 'first commit'
最后執(zhí)行$ git push -u origin master
如果出現(xiàn)這個錯誤:Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
可能是暫存區(qū)沒有文件,通過git add操作可以添加到暫存區(qū)以便commit。
運行 $git add .成功把文件存到暫存區(qū)
接下來繼續(xù)運行$git commit -m 'first commit'將暫存區(qū)的代碼提交到本地倉庫
最后成功push到GitHub上面 $git push origin master
如果push中出現(xiàn)如下錯誤:: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
.這可能是是由于你的git地址采用了ssh方式,切換為https方式
在終端中輸入:
$ git remote set-url origin?https://github.com/YourUserName/YatouTest00123.git
然后再push一下
$git push -u origin master