Title: Theory / Important / CS / Softw / VCS / Git / Reset-Restore
Tags: fromMath mathToDef

Fla: restore --staged files
reset HEAD foo
Effect: Remove change to foo from staging area and put it in working branch
Page: https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History
Prefix: git
Chapter: 2
Section: 4

Instruction: reset labelName
Page: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
Effect: reset HEAD to labelName
Context: git rebase file
Chapter: 7
Section: 6
Abbreviation: t labelName

Fla: reset --soft  <commit>
Effect: put the current branch back to <commit>. Don't change working tree content nor index
Page: https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
Prefix: git
Chapter: 7
Section: 8
Intuition: Commit can be done immediately to go back to same branch content, with a single commit

Fla: reset --mixed  <commit>
reset  <commit>
Effect: Put current branch to  <commit>. Also put commitRef content in index.
Page: https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
Prefix: git
Chapter: 8
Section: 7
Intuition: It seems that everything that was previously in HEAD is now a modification that can be staged or dealt with as any modification

Fla: reset --hard <commit>
Effect: put current branch at <commit>. Put the content of <commit> in index and working directory.
Page: https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
Prefix: git
Chapter: 8
Section: 7
Assuming: Working directory content can be lost, or is already committed. It'll be overwritten
Intuition: Same as if we just commited commitRef. Nothing of extra work is kept.

Fla: reset path
Effect: reset --mixed HEAD path. I.e. put file at path in HEAD to index
Page: https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
Prefix: git
Chapter: 8
Section: 7
Intuition: unstage a file. Reverse of add file

Fla: reset commitRef file
reset --mixed commitRef file
Effect: Put in index file from commitRef
Page: https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
Prefix: git
Chapter: 8
Section: 7

Fla: reset <tree-ish> <pathspec>...
Effect: Copy objects at <pathspect>s from <tree-sh> to the index
Page: https://git-scm.com/docs/git-reset
Prefix: git

Fla: --pathspec-from-file=<file> <tree-ish>
Effect: Copy fields listed in <file> from <tree-ish> to index
Page: https://git-scm.com/docs/git-reset
Prefix: git

Fla: --patch
Effect: Do an interactive reset
Page: https://git-scm.com/docs/git-reset
Prefix: git reset <pathspec>...
Flag abbreviation: -p

Fla: --merge
Effect: Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added).
Page: https://git-scm.com/docs/git-reset
Prefix: git reset <commit>.

Fla: --keep
Effect: Resets index entries and updates files in the working tree that are different between <commit> and HEAD
Page: https://git-scm.com/docs/git-reset
Prefix: git reset <commit>.

Fla: recursively reset the working tree of all active submodules according to the commit recorded in the superproject, also setting the submodules' HEAD to be detached at that commit.
Effect: --recurse-submodule
Page: https://git-scm.com/docs/git-reset
Prefix: git reset <commit>.

Fla: --refresh
Effect: Refresh the index after a mixed reset
Page: https://git-scm.com/docs/git-reset
Prefix: git reset --mixed <commit>

Question: What do `git restore` on tracked <file> that don't exists in source
Answer: Delete <file> from working to respect source state
Page: https://git-scm.com/docs/git-restore

Question: Todo
Answer: restore when not experimental anymore
Page: https://git-scm.com/docs/git-restore