无法推送到远程分支

时间:2017-10-02 18:03:48

标签: git

我在我的主分支中执行以下操作:

git fetch --all

git reset --hard origin/master

然后我创建一个新分支并使用以下命令切换到新分支:

git checkout -b new_branch

我在new_branch中编辑并添加了一些文件。然后我终于commit。但是,当我推动更改时,我收到以下消息:

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.

我已经看过这些帖子,但错误仍然存​​在:

Cannot push to GitHub - keeps saying need merge

Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g

我还缺少什么,我不明白? 只是添加,我还删除了my_branch,再次使用最新的master更新了remote,重新创建了新的分支,仍然遇到了同样的错误,请建议我可能会去哪里错。

2 个答案:

答案 0 :(得分:0)

您可以使用-f开关强制推送。 -f开关强制推送,并将覆盖服务器上的分支。在团队中工作时要小心。

git push -f origin new_branch

答案 1 :(得分:0)

尝试跑步:

git pull

如果此分支是新的,那么您可以使用以下命令设置上游:

git push -u origin new_branch
相关问题