Reputation: 132
I've done a "bad commit" yesterday (the IDE converted tabs to spaces and LF to CRLF) and I want to revert that bad commit, but I don't want the files that has been affected by the commit to get reverted back to the previous commit.
I want the affected files to remain unchanged while removing the bad commit, so I can commit the "new changes" in a new commit.
What's the best way to achieve this ?
Upvotes: 1
Views: 1464
Reputation: 262474
If I understand you correctly, and your working copy is still on that "faulty" HEAD, you could "--amend" the previous commit with the fixed files.
Upvotes: 2
Reputation: 3461
Assuming you didn't commit anything after, just do a git reset --soft HEAD^
.
In the other case, but if you haven't published your history yet (didn't do a git push
so that others already could have pulled it) just make your changes, commit them and use git rebase -i
(interactive) to edit the history.
Upvotes: 1