我昨天还能推,现在却推不动了。

当我使用git push origin master时,我得到一个错误:

$ git remote -v
origin  https://github.com/REDACTED.git (fetch)
origin  https://github.com/REDACTED.git (push)

$ git push origin master
Username for 'https://github.com': REDACTED
Password for 'https://REDACTED@github.com':
To https://github.com/REDACTED.git
! [rejected]         master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/REDACTED.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.

我的工作目录和远程存储库看起来像什么:


当前回答

Use

git push -f origin master

这个是写。

其他回答

如果您创建了一个空的repo并且忘记使用,也会得到这个错误

git init

在你第一次提交之前。

我正在推动一个带有拼写错误“develop”的现有分支,我还没有签出它,相反,我想推动一个名为“envelope”的分支。

因此,分支必须存在,并在本地工作副本上签出,以便能够推送。因此,解决这个错误的方法是不要出现错别字。

做这些:

git rm --cached *
git add .
git commit -m"upload"
git push --set-upstream origin master

检查一下你的网络连接是否正常,速度是否快。

我试图用我的4G移动热点推送,但在近10分钟内出现了这个错误。

附注:在印度,我们的4G网络只有3G速度,所以在做一些花哨的事情之前;看看是否有合理的速度可用:)

我在GitHub帮助(处理非快进错误)中找到了这个问题的解决方案:

你可以通过获取并合并在远程分支上所做的更改和你在本地所做的更改来修复这个问题: $ git获取原点 获取在线存储库的更新 $ git合并起源分支 #将在线更新与本地工作合并 或者,你可以简单地使用git pull一次执行这两个命令: $ git拉起源分支 #获取在线更新,并将其与您的本地工作合并