Suppose I have some changes in my working directory and then I stage all of these changes. Let's call this state-1.
Next, I make some more changes to my working directory. Now, how do return to state-1? Is there a standard/simple command to do this?
This question is very similar but no standard/definite answer on how to actually do it. The closest thing I have found is:
git restore .
But this command is still experimental, and its behavior may change(source). So what's the right way to do this?
CodePudding user response:
Note that, although git restore
is still flagged as "experimental", it is meant to stay around, and there are big chances that git restore .
will keep doing the same thing in future versions.
If you want to keep a trace of your modified files, you can use git stash -k
: this will save the initial content of your worktree in the stash, and then return your worktree to its index state.
If you really don't care about these changes : you can simply run git checkout .
, which does the exact same thing as git restore .
.