How do I revert all local changes in Git managed project to previous state

If you want to revert all changes AND be up-to-date with the current remote master (for example you find that the master HEAD has moved forward since you branched off it and your push is being ‘rejected’) you can use:

# will fetch the latest changes on the remote
git fetch
# will set your local branch to match the representation 
# of the remote just pulled down.
git reset --hard origin/master


Also you can revert some changes simply using this checkout command:

git checkout .



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s