【发布时间】:2019-06-21 00:18:32
【问题描述】:
我正在尝试将我的代码推送到我的远程分支,但一直收到此错误:
! [rejected] (non-fast-forward)
error: failed to push some refs to 'git@github.com:
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
我认为导致这种情况的原因可能是我在 github 上而不是通过本地环境修复了我的 README.md 中的错字。
我查看了所有堆栈溢出并尝试了他们针对此问题提到的命令,例如 git pull 、 git pull --rebase 、 git pull origin master 、 git push --f 和许多其他命令都无济于事。
我也尝试了以下问题的答案,但没有成功:
Cannot push to GitHub - keeps saying need merge
Git pull a certain branch from GitHub
我也试过git pull upstream master,但我得到了这个错误:
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
【问题讨论】:
-
那么
git pull时出现什么错误? -
我知道
Already up-to-date。但它不会让我推送代码。 -
@ElpieKay 这部分实际上令人困惑,因为即使远程上有新的提交并且我们还没有
fetch,它也不会说分支已经分歧。我在回答之前试过这个。