User Tools

Site Tools


git_undoing_things

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]
rpjday [Unstaging staged content]
git_undoing_things [2019/02/26 12:32] (current)
rpjday [Unstaging staged content]
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.txt ยท Last modified: 2019/02/26 12:32 by rpjday