Git之常见异常收集
2017-09-01 10:21
232 查看
1 Push
to origin /master was rejected
参考:https://stackoverflow.com/questions/40142180/android-studio-git-push-rejected
2 failed to push some refs to
描述:$ git push -u origin master
To git@github.com:******/Demo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:******/Demo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方案:
(1).使用强制push的方法:
$ git push -u origin master -f
这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。
(2).push前先将远程repository修改pull下来
$ git pull origin master
$ git push -u origin master
(3).若不想merge远程和本地修改,可以先创建新的分支:
$ git branch [name]
然后push
$ git push -u origin [name]
参考:《push本地代码到github出错》
3 fatal: refusing to merge unrelated histories
描述:这是从远程库pull项目,合并文件发生的异常解决方案:在pull的时候添加 --allow-unrelated-histories。
$ git pull origin master ----allow-unrelated-histories
参考:《 git无法pull仓库refusing
to merge unrelated histories》
4 error:src refspec master does
not match any
描述:在push项目的时候,引发该异常。原因分析:目录中没有文件,空目录是不能提交上去的,获取没有add、commit文件直接进行push了。
解决方案:
$touch README
$git add README
$git commit -m 'first commit'
$git push origin master
参考:《error:
src refspec master does not match any解决办法》
《error:
src refspec master does not match any》
5 fatal: Authentication failed
for 'https://github.com/ ...
描述:使用的https提交,在用SourceTree提交代码时候发生错误,返回的错误提示说:fatal: Authentication failed for 'https://github.com/ ...
解决方案:重新执行Git config命令配置用户名和邮箱即可:
$git config -–global user.name "xxx"
$git config –-global user.email "xxx@xxx.com"
6 ! [rejected] master -> master (fetch first)
描述:To git@git.oschina.net:yangzhi/hello.git! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@git.oschina.net:yangzhi/hello.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushin 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.
解决方案:
可以输入:$ git push -u origin master -f
相关文章推荐
- Spring 常见异常收集
- JAVA常见异常收集
- JAVA常见异常收集
- Git常见错误收集(随时更新.....)
- SQL Server 2008 常见异常收集(持续更新)
- SQL Server 2008 常见异常收集(持续更新)
- okhttp+retrofit常见网络异常收集
- java中碰到的常见异常收集
- git 常见问题收集(持续更新中)
- Java常见异常类的继承关系
- Java常见内存溢出异常分析(OutOfMemoryError)
- Ubuntu10.04安装Git异常汇总
- JAVA运行时异常及常见的5中RuntimeExecption
- 异常收集之:navicatdesignquery.sql.bak 系统找不到指定路径
- 【Github】git push用法和常见问题分析
- Java常见异常(Runtime Exception )小结
- java中常见的几种异常
- 常见十大异常
- java中常见的几种异常
- 【git常见问题】fatal: Not a valid object name: 'master'.