最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】git push出错:error failed to push some refs to

Git crifan 1124浏览 0评论

背景是:

在gitee上已经新建了git的repo:

但是创建了一个README.md

而本地是用

git init

git add

git commit

然后去:

➜  youtubeSubtitle git:(master) ✗ git push –set-upstream origin master

To https://gitee.com/Naturling/xxx.git

! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to ‘https://gitee.com/Naturling/xxx.git

hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: ‘git pull …’) before pushing again.

hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

试了试:

➜  youtubeSubtitle git:(master) git pull origin master

From https://gitee.com/Naturling/xxx

* branch            master     -> FETCH_HEAD

fatal: refusing to merge unrelated histories

➜  youtubeSubtitle git:(master) git status

On branch master

nothing to commit, working tree clean

没用。

git push Updates were rejected because the tip of your current branch is behind

github上的版本和本地版本冲突的解决方法 – CSDN博客

git: "Updates were rejected because the tip of your current branch is behind.." but how to see differences? – Stack Overflow

➜  youtubeSubtitle git:(master) ✗ git fetch origin

还是没有下载下来README

算了去试试:

git push -u origin master -f

➜  youtubeSubtitle git:(master) git push -u origin master -f

Counting objects: 30, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (25/25), done.

Writing objects: 100% (30/30), 14.06 KiB | 2.34 MiB/s, done.

Total 30 (delta 3), reused 0 (delta 0)

To https://gitee.com/Naturling/xxx.git

+ eecfc02…a6117af master -> master (forced update)

Branch master set up to track remote branch master from origin.

的确是-f的force,把原来的README.md弄没了

另外再加吧。

【总结】

在不考虑把原有仓库中的内容覆盖掉(此处原有仓库中有个README.md),则可以直接force去上传:

git push -u origin master -f

转载请注明:在路上 » 【已解决】git push出错:error failed to push some refs to

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
63 queries in 0.076 seconds, using 18.87MB memory