Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Non-fast-forward reject caused loss (Not clear how to recover after a "commit and push" was rejected)
Non-fast-forward reject caused loss [message #1774421] Sat, 14 October 2017 01:22 Go to next message
Mikhail Ramendik is currently offline Mikhail RamendikFriend
Messages: 10
Registered: November 2012
Junior Member
So I made a lot of changes to a Java project, used "Add to Index", and then "Commit and push". And got a "rejected non-fast-forward".

While google told me I need to do a fetch to recover, after a fetch the files were not seen as changed and were not offered for another commit.

So how do I recover from a non-fast-forward rejection and commit and push my changes?
Re: Non-fast-forward reject caused loss [message #1774457 is a reply to message #1774421] Sun, 15 October 2017 09:41 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 78
Registered: August 2016
Member
You need to rebase. Assuming your work should go onto the upstream master branch: rebase your local branch onto the upstream "origin/master" branch. If there are conflicts, resolve them, stage the files, then use "Rebase->Continue" to proceed with the rebase. Once you have successfully rebased your local branch, push again.
Re: Non-fast-forward reject caused loss [message #1774521 is a reply to message #1774457] Mon, 16 October 2017 19:18 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1032
Registered: July 2009
Senior Member
The commits were created in your local git repository but push failed since the commits you tried to push were not a
successor of the current tip of the branch you pushed to. This typically happens if another developer pushed new commits
which you didn't yet download using fetch. If non-fast-forward push would be accepted the commits of the other developer
would appear to be lost (they would no longer be in the history of the branch you pushed to). Hence git rejects this.

So first fetch to download new commits which may have arrived on the server and then rebase your local branch onto the
remote tracking branch of the upstream branch you want to push to.
Re: Non-fast-forward reject caused loss [message #1774522 is a reply to message #1774521] Mon, 16 October 2017 19:20 Go to previous messageGo to next message
Mikhail Ramendik is currently offline Mikhail RamendikFriend
Messages: 10
Registered: November 2012
Junior Member
Thanks! Is there some documentation somewhere about how to do a rebase? I tried but found the files so mangled that I had to restore from a local backup.
Re: Non-fast-forward reject caused loss [message #1774524 is a reply to message #1774522] Mon, 16 October 2017 19:23 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1032
Registered: July 2009
Senior Member
that's described in the EGit user guide
https://wiki.eclipse.org/EGit/User_Guide#Rebasing
Previous Topic:Is it possible to use git merge.conflictstyle=diff3 in Eclipse?
Next Topic:Eclipse pull is causing dirty_worktree error
Goto Forum:
  


Current Time: Tue Sep 18 23:58:13 GMT 2018

Powered by FUDForum. Page generated in 0.01583 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top