Suppose I use git read-tree <sha>
without -um
(because I do not want a merge but rather a simple read).
Now I want to make do the equivalent of the last step of git reset --hard
(make the working tree equal to the index) without changing any refs.
Is there a mechanism in git
to do this?
Equivalently, is there a way to semantically do a git read-tree -u
without any kind of merge, instead simply overwriting the index and working tree with the contents of the given tree-ish?
I tried git checkout-index -a -f
, but it does not remove files in the working directory, only adds them.
I think that is what git restore -- .
does (set working tree just like the index). Now, your last comment makes me think you are looking for git restore --worktree --staged --source <some-commit-id> -- .
which will adjust index and working tree to look just like the commit id you provide.