I want to revert changes made by a particular commit to a given file only.
Can I use git revert command for that?
Any other simple way to do it?
git reset HEAD^ path/to/file/to/revert/in/commit
The above command will take file out of commit, but it will reflect in git status
.
git checkout path/to/file/to/revert/in/commit
The above command will revert the changes (as a result you get file same as HEAD).
git commit
(Pass --amend
to amend commit.)
git push
With this, the file which is already in the commit is removed and reverted.
The above steps should be followed from the the branch where the commit is made.