Arian
Arian

Reputation: 7719

Revert last commit for one file and not the whole repo

I have a repo that has many commits. In Intellij I can see the commits that affected a file and the last three are mine. These commits are buried inside a long history of commits, but for that specific file they are the last three commits.

Is it possible to revert commits for one specific file?

Upvotes: 1

Views: 43

Answers (1)

eftshift0
eftshift0

Reputation: 30212

I guess the simplest thing you can do is to take back that specific file to how it was before the first of the 3 last revisions you are talking about.... too bad you won't be able to link to those 3 revisions.... but you might address them in the revision comment. So...

git checkout earliest-of-the-three-revisions~ -- path-to-file
git commit -m "Reverting file path-to-file

revisions x, y and z produced and undesired effect because of foo bar"

And that should be it.

Upvotes: 3

Related Questions