I need to update working directory and index to the state of some commit.
When I run git checkout
Git updates HEAD
, index
and a working directory
.
I know I can checkout a single file from a commit without updating HEAD
by simply specifying a path to the file. But what is the best way to do that for the entire working directory?
At the moment I'm simply doing:
ID=$(git rev-parse HEAD)
git reset --hard COMMIT_ID
git reset --soft $ID