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.

  • EGit and post-commit hook
  • After checking out Subversion code into Eclipse, how do I get it to build?
  • Why is my git file history lost after performing a move refactor in eclipse?
  • What files should be committed to github for an eclipse project
  • Egit rejected non-fast-forward
  • git gc / git gui: Unlink of file <internal pack file name> failed
  • 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 ?

  • How to configure Eclipse EGit to use custom proxy settings?
  • How to import an Android project in to eclipse with out creating a new one from source?
  • how to tell egit to ignore some file types
  • Cannot commit android “gen” folder to Git
  • Assume Unchanged files not appearing in EGit Staging View
  • Pushing local Git repository to remote Google Cloud Repository from inside Eclipse?
  • 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.