I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous versio
Note, however, that git checkout ./foo
and git checkout HEAD ./foo
are not exactly the same thing; case in point:
$ echo A > foo
$ git add foo
$ git commit -m 'A' foo
Created commit a1f085f: A
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 foo
$ echo B >> foo
$ git add foo
$ echo C >> foo
$ cat foo
A
B
C
$ git checkout ./foo
$ cat foo
A
B
$ git checkout HEAD ./foo
$ cat foo
A
(The second add
stages the file in the index, but it does not get
committed.)
Git checkout ./foo
means revert path ./foo
from the index;
adding HEAD
instructs Git to revert that path in the index to its
HEAD
revision before doing so.