How to remove the local commit history

108 阅读1分钟

Suppose there is a wrong commit version 02cb4fc done by mistake and we would like to remove it:

clipboard1

use git reset --hard fb67002 to restore to the previous version before it:

clipboard2

 

although 02cb4fc disappears from command line, it still exists in Eclipse Plugin.

 

 

In order to also remove the local commit version from Eclipse plugin, we have to use rebase command.

Example: Suppose we could like to remove commit history with description "version2":

clipboard3

clipboard4

clipboard5

resolve rebase error if any:

clipboard6

here we keep the latest version: version3:

clipboard7

clipboard8

Now rebase successfully done, we have the history information below:

clipboard9

for sure the highlighted version are not what we want to reserve:

clipboard10

Use git rebase --onto <target commit version, in my example it is the top commit fa47da9 > <the commit version you would like to remove, in this example it is af713a4 > HEAD:

clipboard11

After successful execution, use an arbitrary git reset command to trigger the refresh, and now you will find that the wrong commit history af713a4 is removed also from Eclipse History view:

clipboard12\