Search code examples
gitgit-commitgitkraken

Remove commit created by changing name to another commit


I was working with GitKraken when I tried to change the name of a commit I just created. I thought it would just change the name but it created another commit instead. I don't know what I did then, but I have the following situation:

enter image description here

I would like to remove those two commits on the right: 'Detector - Tf-idf similarity' and 'WIP on master: Auto...' so that I only have one column with the other 4 commits stacked. Head is on the last commit I want to appear on the graph, 'Added tf-idf similarity'.

Is it possible to completely remove those commits from the project?

EDIT:

If I use the 'reverse commit' option of GitKraken would that solve the problem or would it just make it worse?


Solution

  • In general using git revert to undo one or more commits is the preferred way to go. The main reason for this is that once a branch is published, it can be destructive to actually remove an earlier commit. The git revert command, rather, creates a new commit on top of the branch which functionally undoes some earlier commit. It may be thought of as a mirror image of some earlier commit.

    In Gitkraken, you may revert a commit by right clicking the commit node and then choosing Revert commit. See the documentation for more information.