Reputation: 1037
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:
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?
Upvotes: 1
Views: 71
Reputation: 14459
Your problem here is that there still is a stash on top of your "old", i.e. pre-rename commit: the line WIP on master: Auto stash before...
. Read up on stashing here. If you remove the stash, the old commit will disappear. You should, of course, check if the stashed changes are still relevant before you drop the stash. Git will stash uncommited changes automatically at certain points, as in your case it did before a revert.
Since git commits are identified via SHA hashes, changing the message of an old commit has to create a new commit, since the hash is calculated using (among other factors) the commit message.
In this situation no revert is needed. As @TimBiegeleisen says, you should, of course, not alter commits that are published in any way, but renaming a local commit like you did here is fine and not at all a reason to worry.
Note that only because the commit "disappears" from GitKrakens commit graph does not mean it will be removed completely; it's only not reachable from any of your current branches' HEAD
s. Commits will stick around a while longer, which often is a very helpful feature if resets or rebases go wrong.
Upvotes: 1
Reputation: 521178
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.
Upvotes: 1