Is it me or is the documentation for the --merge
option of git reset
formulated poorly or even incorrectly?
I cite the documentation:
Resets the index and updates the files in the working tree that are different between
<commit>
andHEAD
, but keeps those which are different between the index and working tree (i.e. which have changes that have not been added). If a file that is different between<commit>
and the index has unstaged changes, reset is aborted.
Not speaking about the fail condition of the command and speaking only of the first sentence. Does it mean that the files that don’t differ between <commit>
and HEAD
are not subject to the rollout of <commit>
into the working directory?
I try the following script that doesn't change the file a between HEAD
and HEAD~1
:
#!/bin/bash
git init
echo 1 > a
echo 1 > b
git add .
git commit -m 1
echo 2 > b
git add .
git commit -m 2
echo 3 > a
echo 3 > b
git add .
git reset --merge HEAD~1
cat a
cat b
rm -rf .git
Why do the contents of the file a still get reset when they are supposed to stay unchanged?