Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Reset to previous commit and push
Reset to previous commit and push [message #1798943] Tue, 27 November 2018 17:40 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 801
Registered: July 2009
Senior Member
Another developer recently asked me for help reverting an inadvertent commit. I'd never done that before. After some quick searching, I thought that the best approach was as described here: https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-a-git-reset-and-push-to-remote-works-on-previous-local-commits .

This page is similar to others I've seen, but of course this uses the git command line, as opposed to egit in eclipse.

I tried following this approach on the other developer's workstation, but using egit instead of the git command line. When we tried to push the commit, it was rejected, saying it wasn't "fast forward". It's not clear to me whether this happened because of a mistake we made in the process, or whether the process is inherently flawed.

I'm aware of the different "revert" command in egit, but I believe that does something slightly different, by creating a new commit that essentially repeats the commit before the commit (or set of commits?) we want to revert. I haven't tried that yet, but after our push was rejected, we decided to punt and redo the work on a new branch.

Should that process of resetting to a previous commit and pushing work?
Re: Reset to previous commit and push [message #1798983 is a reply to message #1798943] Wed, 28 November 2018 10:18 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
I think you need to force push. And even then server-side hooks might perhaps refuse your push.
Re: Reset to previous commit and push [message #1799029 is a reply to message #1798983] Wed, 28 November 2018 23:42 Go to previous messageGo to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 801
Registered: July 2009
Senior Member
I noticed that the command-line examples of this did a force. I didn't see any way in Eclipse to specify that on a push.
Re: Reset to previous commit and push [message #1799112 is a reply to message #1799029] Thu, 29 November 2018 22:11 Go to previous message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
In the context menu, Team->Push Branch 'branchName'... has a check box to force overwriting the upstream branch, and in Team->Remote->Push... you can set a "Force Update" flag in the table on the second wizard page for each refspec.
Previous Topic:Egit can't revert commit because local changes to .classpath
Next Topic:LFS - .lfsconfig ignored on initial clone?
Goto Forum:
  


Current Time: Thu Apr 25 22:00:34 GMT 2024

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

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

Back to the top