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.

  • How to change credentials for SVN repository in Eclipse?
  • Netbeans 7 vs Eclipse 3.6 for Java, git and vim
  • Compilation error - package com.google.gson not found in Redhat “Openshift” application
  • How do I get git to stop changing newlines in my files?
  • How to install and use gerrit with eclipse?
  • How to create a patch in IntelliJ IDEA?
  • 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 ?

  • calling cryptdb from eclipse java project
  • How do i solve a dirty index in eclipse?
  • Why is my git file history lost after performing a move refactor in eclipse?
  • subversion eclipse and multiple repositories
  • Should I keep my project files under version control?
  • How to create a new remote branch with EGit?
  • 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.

    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

    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.

    Git Baby is a git and github fan, let's start git clone.