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.
- Access to a file or folder on heroku server
- expression expected while passing fragment class into addSlide method
- Repair links between moved files in Mercurial
- Best practice to build JAR w/ gradle and deploy it - with Jenkins
- How to stage files with JGit in a bare repository?
- Getting all branches with JGit
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 ?
3 Solutions collect form web for “EGit – “Replace With Commit…” doesn't work as excepted”
@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.
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.
(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:
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.