github 常见异常

作者: JAZI | 来源:发表于2018-06-15 19:05 被阅读21次

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

相关文章

  • github 常见异常

    1 Push to origin /master was rejected 参考:https://stackove...

  • 常见异常

    在写java程序时,我们会经常遇到几个特定的异常类,包括在面试的时候面试官也会问常见的异常类 现在我列举几个常见的...

  • 常见异常

    异常的继承结构: 基类为Throwable,Error和Exception继承Throwable,RuntimeE...

  • 常见异常

    1、远程仓库连接不上,异常如下: Exception in thread "main" org.apache.ja...

  • 异常

    几种常见的异常:1.常见的异常现象: 空指针异常类:NullPointerException 类型强制转换异常:C...

  • Android常见异常

    Android常见异常 异常分为编译时异常和运行时异常,当前主要说一下运行时异常,常见的异常如下:NullPoin...

  • 异常处理

    一.常见异常 二.异常分类 三.异常处理

  • Java8之Optional类,巧解NPE

    NullPointerException——空指针异常是程序中常见异常之一,也是导致程序运行失败的常见异常。以前,...

  • 异常

    常见异常: 空指针异常指定类不存在异常数学运算异常非法参数异常请求不允许异常数组下标越界异常 常见错误 堆栈内存溢...

  • 异常处理

    捕获异常 raise语法: 格式:raise 异常名称(‘异常描述’) python中常见的异常

网友评论

    本文标题:github 常见异常

    本文链接:https://www.haomeiwen.com/subject/munmeftx.html