简体   繁体   English

无法推送到远程分支

[英]Unable to push to remote branch

I do the below in my master branch:我在我的主分支中执行以下操作:

git fetch --all

git reset --hard origin/master

Then i create a new branch and switch to the new branch using:然后我创建一个新分支并使用以下命令切换到新分支:

git checkout -b new_branch

I edit and add some files in the new_branch .我在new_branch编辑并添加了一些文件。 Then i finally commit .However, when i push the changes, i get the below message:然后我终于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.

I have already seen these threads,but still the error persists:我已经看过这些线程,但错误仍然存​​在:

Cannot push to GitHub - keeps saying need merge 无法推送到 GitHub - 一直说需要合并

Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. 更新被拒绝,因为您当前分支的提示在提示后面:它的远程副本。 Integrate the remote changes (eg 集成远程更改(例如

What else am i missing, i fail to understand?我还缺少什么,我不明白? Just to add, i have also deleted my_branch , again updated the master with the latest remote , recreated the new branch, still i encounter the same error, please suggest where i might be going wrong.补充一下,我还删除了my_branch ,再次用最新的remote更新了master ,重新创建了新分支,但我仍然遇到同样的错误,请指出我可能出错的地方。

You can force your push with the -f switch.您可以使用 -f 开关强制推送。 The -f switch forces the push, and will overwrite the branch on the server. -f 开关强制推送,并将覆盖服务器上的分支。 Use with caution when working in a team.在团队中工作时请谨慎使用。

git push -f origin new_branch

Try running:尝试运行:

git pull

If this branch is new, then you can set the upstream with:如果这个分支是新的,那么你可以设置上游:

git push -u origin new_branch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM