SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Saturday, March 5, 2011

Revert changes to previous version in git

As a developer, we tends to make mistakes when we are committing our code to the repository.When we are using git, its too ease to revert.


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<genwor@gmail.com>
Date:   Sun Mar 6 12:55:56 2011 +0530

    style changes
$

Now we can revert the commit ‘style changes’

$ git revert ac59a2a1d67aca74895ceddbc709a467c572144b

No comments :

Post a Comment