Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » How to checkout previous revision?
How to checkout previous revision? [message #932047] Wed, 03 October 2012 19:37 Go to next message
Luís de Sousa is currently offline Luís de SousaFriend
Messages: 214
Registered: July 2009
Senior Member
Dear all,

I have an Acceleo project in my local Git repository that is all messed up and I'd need to revert back to a previous revision. In the documentation it says I must right click on a revision item in the History view and select Commit Revert. The problem is that the History view is shown completely empty. Is there any other way to revert to a previous revision? or even to checkout the project at an earlier revision?

Thank you,

Luís
Re: How to checkout previous revision? [message #932462 is a reply to message #932047] Thu, 04 October 2012 05:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Luís,

Are you sure you don't want to do a Reset Hard? I.e., do you really
want to create a new commit and undoes previous commits that you'll
subsequently push upstream?

Note that the history view has buttons that affect for what things it
shows the history and there's the link button too that makes what it
shows depend on the selection... Try them out and see how it changes
what's displayed depending on what you have selected in the repositories
view or in the package/project explorer.


On 03/10/2012 9:37 PM, Luís de Sousa wrote:
> Dear all,
>
> I have an Acceleo project in my local Git repository that is all
> messed up and I'd need to revert back to a previous revision. In the
> documentation it says I must right click on a revision item in the
> History view and select Commit Revert. The problem is that the History
> view is shown completely empty. Is there any other way to revert to a
> previous revision? or even to checkout the project at an earlier
> revision?
> Thank you,
>
> Luís


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to checkout previous revision? [message #933060 is a reply to message #932462] Thu, 04 October 2012 17:40 Go to previous messageGo to next message
Luís de Sousa is currently offline Luís de SousaFriend
Messages: 214
Registered: July 2009
Senior Member
Hi Ed, thank you for your reply. Navigating through the Repository explorer I found that the History only shows contents when the Branches tree node is selected.

The problem is that when I right click over a revision and select checkout the project doesn't show up in the Workspace. What else do I need to do to get the project code of that particular revision?

Thank you,

Luís
Re: How to checkout previous revision? [message #933088 is a reply to message #933060] Thu, 04 October 2012 18:17 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
You can show the history of the repository as a whole by right-clicking the repository root in the Git Repositories view and selecting Show In -> History.

Or you can enable the link "Link with Editor" toggle and simply select the repository root.

Or you can right-click any project in an Explorer view , run Team -> Show in History and enable the toggle called "Show all changes in repository containing selected resource."


There are probably other ways to get here as well.

The "checkout" right-click action on a history entries works fine however you get there. Of course Git checkout applied to a commit doesn't revert the repository. it simply puts your working directory and index in a state that corresponds to the given commit.

If you pushed one or more commits and now you want to undo them, you should run "revert" on each of the commits (in reverse order), not "checkout". Then push the resulting new commits.

If you have not yet pushed any of the problematic commits, or not even committed the changes yet, then the operation you want is "reset", in other words, move the branch pointer back, optionally adjusting the index and working directory as well. In this last case you probably want the "hard" variant, which will adjust the index and working directory as well as moving the branch pointer.



Re: How to checkout previous revision? [message #933106 is a reply to message #933088] Thu, 04 October 2012 18:40 Go to previous messageGo to next message
Luís de Sousa is currently offline Luís de SousaFriend
Messages: 214
Registered: July 2009
Senior Member
Hi Shapiro, thank for the details.

What I need is indeed the checkout I believe, since I do not want to forego the commits that are problematic, I just want to check what was working or not a few revisions ago. The problem is that when I issue a checkout on a commit the project doesn't show up in the package explorer, when I switch back to the Acceleo perspective.

Thank you,

Luís
Re: How to checkout previous revision? [message #933118 is a reply to message #933106] Thu, 04 October 2012 18:55 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
So you're doing a kind of git bisect, ok. Checkout is exactly what you want then.

Is it possible that the .project file was created after the commit you checked out? In that case the Eclipse project wouldn't have existed at the given revision. so Eclipse would not show it.

Re: How to checkout previous revision? [message #933158 is a reply to message #933118] Thu, 04 October 2012 19:48 Go to previous messageGo to next message
Luís de Sousa is currently offline Luís de SousaFriend
Messages: 214
Registered: July 2009
Senior Member
R Shapiro wrote on Thu, 04 October 2012 14:55

Is it possible that the .project file was created after the commit you checked out? In that case the Eclipse project wouldn't have existed at the given revision. so Eclipse would not show it.


I checked in the Repository browser, the .project file was added with the first commit.

I believe this situation not to be that different from checking out an existing project into a new Workspace. What would be the procedure in that case?

Thanks for helping,

Luís
Re: How to checkout previous revision? [message #933187 is a reply to message #933158] Thu, 04 October 2012 20:27 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
I just did some testing here. If I do an explicit checkout of an earlier revision, the project structure remains as it was. Only the file contents change.

If you checkout a different branch, rather than a revision from history, do you see the same problem? From the project perspective, checking out an arbitrary revision should be essentially the same as checking out a branch.


What version of EGit are you using?


Re: How to checkout previous revision? [message #934183 is a reply to message #933187] Fri, 05 October 2012 18:35 Go to previous message
Luís de Sousa is currently offline Luís de SousaFriend
Messages: 214
Registered: July 2009
Senior Member
Hello again,

I found out what's wrong and it is not good. When I understand that something was wrong with my code and decided to go back to a previous version I deleted the project from the Workspace, thinking that would be the correct procedure (I occasionally do it this way with SVN). It happens that this not only deleted the project from the workspace but also from the repository.

I have alternative backups, but I'm going back in time about 2 months :S

Thanks for all the help in any case,

Luís
Previous Topic:Checkout private repositories
Next Topic:Data transfer without file system
Goto Forum:
  


Current Time: Fri Mar 29 00:33:06 GMT 2024

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

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

Back to the top