Michael Michael - 3 months ago 18
Git Question

Inverse of git reset --soft

git reset --soft
will keep your current changes, but move HEAD to another commit.

I am looking for an inverse of this operation, so that HEAD would remain stationary but state of all files would be set to the same as in commit CommitX.

I found a workaround:

git diff --no-prefix HEAD..CommitX | patch -p0


But I am wondering if there is a simple git command to do that.

Answer

You can use git read-tree command to read particular tree into index. With -m -u options it will also update working directory.

git read-tree -m -u CommitX
Comments