Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

egit

I've run into a problem with my origin/branch being out of sync with my local branch, see below

My commit history

When I try to PUSH from my local "staging" branch to the origin/staging branch I get the "rejected - non-fast-forward" error.

I use Eclipse with the EGit module on a windows PC.

From another post here I see that I can resolve my issue with the "git push --force origin staging" to over-ride the origin/staging branch with my local branch.

However, I don't see that option with EGit, and I don't see how to open a console in EGit to do this?

Does anyone know if I can do this within EGit?

OK - fixed my own issue. It appears I had issues with Commits that had not been Pushed back to origin/staging. Found an overview here on using the "git reset XXX : without --hard" which resets the branch marker, but keeps the local changes for later recommits.

Thanks, Jason

like image 930
Jason Avatar asked Sep 06 '12 14:09

Jason


People also ask

How do I force a git push?

To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch). See the <refspec>... section above for details. Force an update only if the tip of the remote-tracking ref has been integrated locally.

How do you commit in EGit?

1) You must COMMIT your changes at the file or folder level. This only commits them to a local git repository. To do the local commit, select the file, right-click menu, Team -> Commit.


1 Answers

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

  1. Team -> Push Branch <name of branch> ...
  2. Force overwrite of branch on remote if it exists and has diverged
like image 99
Tomek Samcik Avatar answered Sep 25 '22 06:09

Tomek Samcik