1.输入:git push -u origin master
错误信息:.Permanently added the RSA host key for IP address 'XXXXXXX' to the list of known hosts.
按照提示信息将IP加入到etc/hosts文件里面就行。
2.输入:$ Git remote add origin git@github.com:gitaccount/gitdemo.git
出错信息:fatal: remote origin already exists.
解决办法:输入: $ git remote rm origin
3.输入:$ git push -u origin master
出错信息: ! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:fangxuu/learngit.git'
hint: Updates were rejected because the remote contains work that you do
解决办法:输入:$ git pull --rebase origin master
按照出错提示用git pull命令即可。出现这个问题应该是我先在github上建立了仓库,再在本地建立仓库,这样github上的readme.md文件没有同步到本地。
好了,第一次添加远程库遇到的三个问题先写下来
输入:git push -u origin master
推送成功!有点开心。