Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_undoing_things [2019/02/26 12:15] – [Undoing all staged and unstaged changes] rpjdaygit_undoing_things [2019/02/26 12:32] (current) – [Unstaging staged content] rpjday
Line 114: Line 114:
 <code> <code>
 $ git reset --hard $ git reset --hard
 +</code>
 +
 +==== Unstaging staged content ====
 +
 +From ''man git-reset'':
 +
 +<code>
 +       git reset [<mode>] [<commit>]
 +
 +       ...
 +
 +           --mixed
 +               Resets the index but not the working tree (i.e., the
 +               changed files are preserved but not marked for commit)
 +               and reports what has not been updated. This is the
 +               default action.
 +</code>
 +
 +Example:
 +
 +<code>
 +$ git reset -- README
 +</code>
 +
 +==== Restoring accidentally-deleted files ====
 +
 +Recall:
 +
 +<code>
 +git checkout [<tree-ish>] [--] <pathspec>...
 +    Overwrite paths in the working tree by replacing with the
 +    contents in the index or in the <tree-ish> (most often a
 +    commit). When a <tree-ish> is given, the paths that match
 +    the <pathspec> are updated both in the index and in the
 +    working tree.
 +</code>
 +
 +To restore file from HEAD:
 +
 +<code>
 +$ git checkout HEAD -- <file>
 +</code>
 +
 +To restore file from index:
 +
 +<code>
 +$ git checkout -- <file>
 </code> </code>
  • git_undoing_things.1551183355.txt.gz
  • Last modified: 2019/02/26 12:15
  • by rpjday