Liyang
Liyang

Reputation: 75

How to remove file changes from a specific commit

this is my git log

commit 1d739fb5
commit message: Merge otherBranch

commit 1c2a12b9
file change : hibernate.cfg.xml

commit 8d9a1c49
file change : db.sql
              ...


commit 7235ac29
file change : hibernate.cfg.xml
              ...

I just want remove 7235ac29 commit the file hibernate.cfg.xml file change, how do i do that?

Is it possible ?

Upvotes: 3

Views: 2298

Answers (1)

vhula
vhula

Reputation: 497

If you've already pushed your changes then it's not a good idea to remove the commit from the history. But it's still possible to discard your changes.

I assume that you have already pushed your commit to the remote repository and you want to discard all the changes made in that commit.

In this case, you should revert the commit: git revert 7235ac29. It will create another commit that cancels all the changes made in the 7235ac29 commit. You will have to resolve conflicts probably.

Upvotes: 2

Related Questions