Resetting a single file is possible using Git.
How to restore a single file
In Git versions 2.23 and higher, git restore
natively supports resetting a single file.
|
|
The above restores path/to/file.txt
to the prior commit.
In addition, restoring from another branch is possible:
|
|
The -s
option specifies a source (my-feature-branch
in this case).
How to reset a single file
In Git versions that predate 2.23, the following command will reset a single file:
|
|
Anything after the --
is treated as a filename in unix.