0

Git reset working directory to last commit

If you want to permanently reset your Git working directory (assume master) to the last commit you can issue the following commands:

First reset the changes

git reset HEAD --hard

then clean out everything untracked

git clean -fd

Note that doing this means that all changes since the last commit will be lost. The best thing you can do is create a branch for experimental features and keep your master branch for milestone releases, then going back to stable code is just a case of issuing the following command:

git checkout <branch name>

Leaving your experimental code available in the working directory of the other branch.

Jason Edwards