The documentation says:
The hook is given three parameters:
- the ref of the previous HEAD,
- the ref of the new HEAD (which may or may not have changed), and
- a flag indicating whether the checkout was a branch checkout (changing branches,
flag=1
) or a file checkout (retrieving a file from the index, flag=0
).
In your case, your HEAD has not changed. You might have some modified files initialized back to the HEAD content, but other than that, all files already checked out are still checked out:
git show --pretty="" --name-only HEAD
Since you have not changed branches, the flag is set to 0, even if all files were already checked out. So there is no easy way to see which ones were modified and reset to HEAD content.
The key is: that post-checkout hook cannot affect the outcome of 'git checkout'.
On other words, the index and working tree already reflect their final state (and don't remember what was there before)
If you need a list of files reset by a git checkout .
, it is best to do first a git stash
.
Then a git checkout
: your post-checkout hook can then use git stash show
in order to list the files that were present before the checkout.