Pagine

Friday 26 May 2017

How to revert uncommitted changes with git

Let's suppose you edited a file on the production working directory, but didn't commit it. On your last push, you edited it, and the changes in production aren't needed anymore. So, your goal is to erase changes on this file and reset the file to the last committed version:
$ git checkout myfile.txt
This command is really nice if you want to restore a deleted file. You can also specify a commit pointer to use (useful if you stash [1] your changes):
$ rm myfile.txt
$ git checkout HEAD myfile.txt

Link

[1] Stashing your changes with git

No comments:

Post a Comment