Sublime Forum

Remove a commit

#1

I need to be able to remove a specific committed file or at least back out of that one commit (yeah, I committed a secret). Is there a way to do this using Sublime Merge or do I do the usual “flaming hoop” routine?

uncommit a file
revert or remove a previous commit

0 Likes

#2

Reverting a commit generally makes a new commit that reverses the changes of the commit being reverted. That stops them from being in the immediate working copy, but there’s still a historical record of it having happened.

For something like this, you need a rebase operation that modifies the first commit to have added the file.

Merge does various things that perform rebases for you, though there may be no substitute for doing it manually. One thing you can do is select commits in the tree and use the context menu to Edit Commit > Drop Selected Commits to rewrite the history as if that commit was never made (though if there were other changes in it that you want to keep, you would need to make sure to preserve those.

Something to note is that if you’ve pushed the commit anywhere, although you can force push the branch later, there’s always the possibility that someone has seen the secret.

2 Likes

#3

I would be remiss if I didn’t comment on the security aspect of this for posterity:

If the secret was ever pushed, consider it compromised & change it as soon as possible.

1 Like