转自 https://blog.csdn.net/u010042585/article/details/79378726
将本地项目push到GitHub时遇到的问题
1、$ git remote add origin时出现fatal: remote origin already exists.错误
只要执行一下git remote rm origin 在执行git remote add origin 就可以啦
2、执行git push -u origin master(使用的时HTTPS连接,没有验证SSH连接)时出现remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com问题解决办法:
在输入Username for 'https://github.com': XXX 后弹出的窗口需要输入密码,这个密码不是GitHub登录密码而是gitab 的访问令牌
3、$ git push -u origin master
fatal: HttpRequestException encountered.
Username for 'https://github.com':
To https://github.com/
! [rejected] master -> master (fetch first)
error: failed to push some refs to
错误解决办法
执行一下:git pull --rebase origin master
4、
[root@node2 learngit]# git push origin master
To http://192.168.0.74:9675/zihao/test.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'http://192.168.0.74:9675/zihao/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决:
先pul 再push
[root@node2 learngit]#git pull http://192.168.0.74:9675/zihao/test.git
[root@node2 learngit]# git push origin master