Ronald
Ronald

Reputation: 2917

how to revert one single file of a commit with multiple files

Assume that I have committed 5 files. After I have committed I have noticed that I need to undo changes on one file of these 5 files. Is this possible ? if not what is the best why to undo the changes on one file?

Upvotes: 1

Views: 1071

Answers (1)

eftshift0
eftshift0

Reputation: 30166

Expanding (and with a little adjustment on his comment) from ChatterOne, if what you want to is amend the revision (and forget about the bad revision):

git checkout HEAD~ -- path-to-file
git commit --amend --no-edit # replace the revision that I just created with this new revision I'm creating

Upvotes: 2

Related Questions