1.Revert changes to particular file after committing
$ git checkout master $ git add filename $ git commit filename
As per the scenario, we have committed locally.Now we want to revert the local changes and replace with the latest from the repository.
git checkout filename
This will replace the local file with the latest from the repository.
1.Revert changes to particular file after pushing
We have pushed the changes to the repository,now we want to revert the changes with the previous version.
$git log -1 $commit ac59a2a1d67aca74895ceddbc709a467c572144b Author: jude<email@example.com> Date: Sun Mar 6 12:55:56 2011 +0530 style changes $
Now we can revert the commit ‘style changes’
$ git revert ac59a2a1d67aca74895ceddbc709a467c572144b