What does `git reset --mixed` do in terms of index if there's no current branch -


as understand when run git reset without parameters , paths defaults --mixed git manual describes as:

resets index not working tree (i.e., changed files preserved not marked commit) , reports has not been updated.

i'm wondering reset to? assume reads tree index file using git read-tree, find tree? other options explain tree found in head file points commit or branch , hence tree hash can resolved.

however, i've used git read-tree aa23 put tree index , head file contains following:

ref: refs/heads/master 

but there's no branch created yet. tree contains 2 files:

$ git ls-files -s 100644 a1deaae8f9ac984a5bfd0e8eecfbafaf4a90a3d0 0       f1.txt 100644 9b96e21cb748285ebec53daec4afb2bdcb9a360a 0       f2.txt 

and when run git reset no errors, git status reports no changes , git ls-files -s reports no files. did index reset to?

when running git reset on unborn branch, git explicitly uses semi-secret empty tree the target of reset:

unborn = !strcmp(rev, "head") && get_sha1("head", oid.hash); if (unborn) {         /* reset on unborn branch: treat reset empty tree */         hashcpy(oid.hash, empty_tree_sha1_bin); } else if (!pathspec.nr) { 

with top level tree being empty, correct (at least notionally) result resetting index entry path p remove p index.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -