27

I just made some bad commits with egit that I would like to delete.

Some bad commits I want to delete

How do I delete commits from egit?

Thanks!

EDIT: I tried a hard reset a few times but it didn't do anything. Hard reset screen

EDIT 2: Hard reset does rollback changes indeed, but I want them to completely disappear from the history as if I never made these commits.

1

3 Answers 3

40

RightMouse on your Repository and click on "show in -> history". You should select the last commit before your last "fetch"...most of the time its the second commit under your current HEAD. RightMouse on that commit and "reset -> Hard" (will reset all your commits AND local workspace changes to the selected commit).

you should see the up-arrow changing into an down-arrow, meaning that your commits are deleted and that your repository is outdated. Use "fetch" & "rebase" to be up to date.

4
  • "Fetch" fetches the remote repo in the local repo, and "rebase" asks for selecting another branch then the current branch... Didn't delete anything, only rolls back changes. Am I doing something wrong?
    – jobukkit
    Dec 10, 2012 at 17:51
  • 1
    seems so, because rebase would normaly "update" your "outdated" files in the local repo or launch the conflict manager tool. if my instruction dont work for you -> setup a new egit when you have only bad commits on your repo.
    – Frank
    Dec 20, 2012 at 14:45
  • Note that this didn't work for me. It worked locally, but it wouldn't let me push this change to the central repository. It rejected it for "non-fast-forward". What ended up working, which isn't quite what the OP asked for, was "Revert Commit". It let me push that to the central repo. Aug 6, 2021 at 20:18
  • 10 years later, this helped me
    – Wonka
    Jun 17, 2022 at 9:34
5

Note that Egit3.0 in Kepler allows you to hard reset to any treeish expression you want:

enter image description here

But once hard reset, you still need to git push --force after that: if you don't the history of your upstream repo would still list that commit.

-1

You can do a hard reset but be carefull with that !! Here's some more info: Delete commits from a branch in Git

1
  • I have tried a hard reset a few times, but that didn't delete my commit... Am I doing something wrong?
    – jobukkit
    Nov 23, 2012 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.