Iria
Iria

Reputation: 185

undo git changes on a file

I made several commits and pushed them so, remote looks like this:

A-B-C-D---...--N

Commit B is of 4 modified files (a, b, c, d). I realized that I only want changes in file a, so I need to discard b,c,d changes. The problem is that I have already pushed the commit and made more commits that I have pushed as well. File a has been modified a lot in later commits. Problem is that when I click on Visual Studio 2022=> Manage branches => revert, only b and c file changes have been reverted, therefore a and d are still there. I get a pop up saying that it has been an error, but there is nothing on the output window. Question is: how do I do this using git bash?

Upvotes: 0

Views: 508

Answers (1)

ErniBrown
ErniBrown

Reputation: 1372

With git bash you find the sha of the commit (use a gui, or git log), then you simply launch git revert <SHA> This will create a new commit that revert the changes you made in the original commit.

Upvotes: 1

Related Questions