EGit on Eclipse: How to git push --force?

北战南征 提交于 2019-11-28 09:10:28

I have just come across a similar issue and here's what I did:

  1. Team -> Push Branch...
  2. Force overwrite of branch on remote if it exists and has diverged

Are you sure you want to overwrite the remote branch and lose all those commits?

If there are commits on the remote branch that aren't in your local branch, you should merge them into your local branch before pushing

For example, whilst on your local staging branch:

git merge origin/staging

However, if you're sure, then I suggest you check the "Force update" option on the push refspec.

It's a little complicated to get to, but the EGit user guide explains it when discussing Pushing to other Repositories, and the specific section that mentioned the "Force Update" option is in the section on Push Ref Specifications

Edit 0: With respect to your failed merge, I've not yet encountered a merge that fails outright rather than result in a conflict, and it appears it may be a known issue

If you do a force push, you will lose everything added to origin/staging after fixing the missing Location: string in the header, and you'll break everyone else's branches. I don't think that's what you want. You probably want to do a pull first, then the push will work just fine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!