将提交推送到 github 存储库抛出错误

Pushing commit to github repository throwing error

我遇到的错误:

To https://github.com/Git-Username/Repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/user/repo.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.

我正在执行的命令:

git push origin master

当我用谷歌搜索这个错误时,我已经尝试了几乎所有的方法,我尝试了拉等。

I tried pulling etc.

拉动应该足以解决问题。

但如果您的本地历史是正确的 (git log),并且您是该存储库的唯一推送者,您也可以简单地强制推送

git push --force -u origin master

这将覆盖遥控器上的历史记录。