前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Git - git push origin master 报错的解决方法

Git - git push origin master 报错的解决方法

作者头像
KangVcar
发布2018-07-06 15:14:09
7620
发布2018-07-06 15:14:09
举报
文章被收录于专栏:kangvcarkangvcar

git push origin master 报错的解决方法

错误提示如下

123456789

[root@linux1 php]# git push -u origin master To git@github.com:kangvcar/Results-Systems--PHP.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:kangvcar/Results-Systems--PHP.git'hint: Updates were rejected because the remote contains work that you dohint: 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.

原因

GitHub远程仓库中的README.md文件不在本地仓库中。

解决方案1

我们只需加上 -f 参数即可push成功

12345678910111213141516171819202122

[root@linux1 qimo]# git push -f warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the current behavior after the default changes, use: git config --global push.default matching To squelch this message and adopt the new behavior now, use: git config --global push.default simple See 'git help config' and search for 'push.default' for further information. (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 'current' instead of 'simple' if you sometimes use older versions of Git) Counting objects: 53, done. Compressing objects: 100% (53/53), done. Writing objects: 100% (53/53), 1.35 MiB | 55.00 KiB/s, done. Total 53 (delta 8), reused 0 (delta 0) remote: Resolving deltas: 100% (8/8), done. To git@github.com:kangvcar/Results-Systems--PHP.git + fbe05e8...70b187d master -> master (forced update)

解决方案2

我们只需加上 –rebase 参数然后再重新 push 一次即可

12

[root@linux1 qimo]# git pull --rebase origin master [root@linux1 qimo]# git push -u origin master

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-11-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • git push origin master 报错的解决方法
    • 错误提示如下
      • 原因
        • 解决方案1
          • 解决方案2
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档