Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Resetting a specific file
Resetting a specific file [message #759029] Fri, 25 November 2011 16:39 Go to next message
Harry Houdini is currently offline Harry HoudiniFriend
Messages: 137
Registered: February 2010
Senior Member
Hello,

I made some modifications on a file, but I don't want to commit them, and want to revert it to the version stored on the remote server (which may be newer that the file I originally got).

In Subversive, it was the "Override and update" command.
In EGit, I found the Reset command, but it seems to be applyable only to the full project.

What should I do ?

Thanks.
Re: Resetting a specific file [message #759052 is a reply to message #759029] Fri, 25 November 2011 20:39 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
You can't revert directly to with another repository but you can revert a file to its state as of the last fetch or pull from that repository. This is supported by the "Replace With..." operation, with the remote-reference as the target. This is usually something like 'origin/master' under "Remote Tracking". Replace With can also be used to revert to the last locally committed version, or the last staged but not yet committed change, or some other local branch.

Note that this is a completely local operation in all cases. In particular it will not fetch any new changes from a remote repository. That's a separate operation.
Re: Resetting a specific file [message #759321 is a reply to message #759052] Mon, 28 November 2011 11:25 Go to previous messageGo to next message
Harry Houdini is currently offline Harry HoudiniFriend
Messages: 137
Registered: February 2010
Senior Member
Thanks.

I would have liked to be able to do that from the "Team Synchroniez" view.
Re: Resetting a specific file [message #759348 is a reply to message #759321] Mon, 28 November 2011 13:09 Go to previous messageGo to next message
Dariusz Luksza is currently offline Dariusz LukszaFriend
Messages: 40
Registered: July 2010
Member

As R Shapiro said you can use "Replace With" in eg. package explorer context menu.

You can also use "Overwrite" from file context menu in Synchronize view in "Workspace" presentation model. The "Overwrite" in Synchronize view is equivalent to "Replace With" -> "HEAD revision" from package explorer file context menu and it will restore version latest version of given file in this branch. If you would like to restore version from another branch you need to use "Replace With" -> "Branch, Tag, or Reference..." and then select source branch.
Re: Resetting a specific file [message #759352 is a reply to message #759321] Mon, 28 November 2011 13:24 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
The nightly build has an 'Overwrite' option in the Synchronize view. I don't know for sure what the semantics are here, in particular where it will overwrite from the HEAD, the Index, or the last commit fetched from whichever remote you're synchronizing against. One of the egit authors can no doubt answer that question.

Either way, I think you'll find it more straightforward to perform operations like this from an Explorer view using 'Replace With'. It's a bit roundabout to go through the work of synchronizing if you already know exactly what you want to do. Certainly 'Replace With' is much more explicit about what it will be doing.

In general I've noticed a tendency for Eclipse users to go through synchronization for no particular reason. This is true with subversive/subclipse and cvs, as well as egit. Unless you want to do detailed comparisons of multiple files, there's no reason in any Team provider to pay the price of synchronization.





[Updated on: Mon, 28 November 2011 13:28]

Report message to a moderator

Re: Resetting a specific file [message #759449 is a reply to message #759352] Mon, 28 November 2011 17:29 Go to previous messageGo to next message
Harry Houdini is currently offline Harry HoudiniFriend
Messages: 137
Registered: February 2010
Senior Member
Thank you, guys, it seems you provided me all the needed info.
Re: Resetting a specific file [message #1721868 is a reply to message #759352] Mon, 01 February 2016 08:04 Go to previous message
Terence Miller is currently offline Terence MillerFriend
Messages: 6
Registered: July 2009
Junior Member

I trapped in similar question and feedl like beeing in yak hair studio.
I am in the sync view as i want to sync my local changes with remote master.
Then after some time i have the situation i wanna throw away my changes and leave the one on the master as it which conflits my changes, that means don't change it locally go back to last fetch from remote master.

I choose "overwrite".

The first thing which feels wrong is that i have to mark the file as "merged" to get away the "conflict state" . Why is that so .. ? Overwite is pretty clear what is says, so why acklowledge that again - useless.
The second thing which is much worse is that when i commit now the repo the "unchanged file" is listed in the commit view ..what the hell? I didnd't changed it and said use the one from remote master like last fetch. There is no need to commit the file with changes from other devs from master.
The plugin should here remote the change from index, shouldn't it?
Previous Topic:jgit S3 pull fetches many unecessary/duplicate pack..idx files
Next Topic:SSH algorithm negotiation failed
Goto Forum:
  


Current Time: Sun Feb 14 13:02:38 GMT 2016

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

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