Mickäel A.
Mickäel A.

Reputation: 9357

EGit - "Replace With Commit..." doesn't work as excepted

I'm using EGit with Eclipse Indigo SR 2 Build 20120216-1857.

Almost everything works well, except the Replace With -> Commit... function. In fact it works, but doesn't restore the project exactly like it was because it left the new files that I added since.

It looks like it does a kind of a mix between current HEAD and the commit I choose to restore. What I really want is to replace the content of my project with a previous commit like it does when you switch between branches.

Is there any solution ? And does anyone knows if the lastest version of Eclipse provide a fully working version of EGit ?

Or am I misunderstanding this feature ?

Upvotes: 3

Views: 1549

Answers (3)

VonC
VonC

Reputation: 1324537

The "Replace with" I know in Egit is about git checkout (and not git revert, as robinst comments below).
And checkout is not the same than reset.

What I really want is to replace the content of my project with a previous commit like it does when you switch between branches.

That would be closer to the feature "Reset".
Selecting the "hard reset" would remove any private file and completely restore both the index and the working tree to the selected commit.

reset in Egit

(from "How to delete commits with Egit?")

hard - the HEAD points now to the new commit, the index and the working tree are updated.

You also can see it in this tutorial:

reset in Egit bis

Upvotes: 3

Mickäel A.
Mickäel A.

Reputation: 9357

@VonC pointed me towards one solution but that's not really what I want.

I tried the Reset command but first, I had to tag the commit to be able to choose it. Then it changes the whole master branch and canceled the next commits. In fact I don't want to change any branch or to delete any commits, I just want to be able to return to a previous one to see the whole code and eventually run it.

Finally I could have it to work using Checkout on the commit. To see all the commits : Right click on your project -> Show In -> History

It will not modify any branch your were working on but just replace the content of your project by the one the commit has saved.

Upvotes: 3

ogzd
ogzd

Reputation: 5692

Newly created files are not in git index (untracked) unless you add them into. Since you are reverting your workspace back to a commit, only your tracked files (added to git index) will be modified. Newly created files are not touched.

If you want to delete your untracked files:

git clean -f -d will do it.

Upvotes: 0

Related Questions