Search notes:

git restore

Main options

The three main options of git restore are

Undoing an added file

Using --staged unstages a file that was added to the staging area:
get restore --staged added-file.txt

Getting back a deleted file

rm foo.c
git restore foo.c

Getting an «old» file

git restore --source HEAD~42 foo.c

Restore a file to a different directory

A file of a given commit can be restored to another directory like so
mkdir old-version
git --work-tree ./old-version restore -s 9442d6c77c path/to/file.txt
cd old-version/path/to
ls file.txt
Compare with git show

See also

Two new git commands meant to reduce git checkout confusion
git reset, git revert
git commands

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759391073, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/version-control-systems/git/commands/restore(74): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78