Git 推送被拒绝。推送某些引用失败,当前分支的尖端位于其远程对应分支的后面

Git 推送被拒绝。推送某些引用失败,当前分支的尖端位于其远程对应分支的后面,git,Git,我试图将django项目保存到github,但在运行git push命令后出现错误 ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/kp1311/Careerboost' hint: Updates were rejected because the tip of your current branch is behi

我试图将django项目保存到github,但在运行
git push
命令后出现错误

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/kp1311/Careerboost'
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.

在StackOverflow中可以多次找到此错误消息,但在Google上搜索时,结果很难掌握

您正在推送到一个分支(主分支或其他分支),该分支是您不久前在本地克隆的。然而,与此同时,有人将新内容推送到了那个远程分支机构

为了能够推动,您必须执行以下操作之一:

git push -f
这将用您的内容覆盖远程内容。其他人修改的所有内容现在都被您的内容替换(自第一次发散提交以来)

这不是一个单独的命令,但我有点匆忙,所以我只在这里概述一下:首先,隐藏编辑并删除提交(
git reset--soft
git stash
),然后
git pull
然后git
stash pop
git commit


现在您可以
git push
,它将把您的编辑置于其他人的编辑之上。您必须手动解决冲突。

这不是一个命令。
git-pull-rebase
可以工作……您通常可以运行
git-pull
(取决于您需要什么)。我重新安装了git,一切正常
git pull + rebase