Differences

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

Link to this comparison view

Both sides previous revision Previous revision
git_undoing_things [2019/02/26 12:24] – [Unstaging staged content] rpjdaygit_undoing_things [2019/02/26 12:32] (current) – [Unstaging staged content] rpjday
Line 138: Line 138:
 </code> </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>
  • git_undoing_things.1551183854.txt.gz
  • Last modified: 2019/02/26 12:24
  • by rpjday