Search code examples
eclipsegithubegit

Pulled branch with deleted files with eGit


I've made a massive mistake and deleted several files directly on my remote repository. I pulled these changes thinking I would only be pulling the still present files, however I lost all the files on my local repository that I had deleted on the remote one. This caused my maven project to break and I couldn't do anything with it anymore. Is there any way to revert my changes?


Solution

  • General idea:

    If your local files were committed, you can reset everything to before the git pull:

    git reset --hard HEAD@{1}
    

    See git reflog to make sure HEAD@{1} is the right commit.
    See an example here.


    For Eclipse itself, you can go first to the reflog view

    https://wiki.eclipse.org/images/e/e3/Egit-1.2-reflog-view.png

    Then you can right-click on a past commit, and select "Reset > Hard"