1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-06-08 01:46:02 +02:00
tldr/pages/common/git-restore.md
Managor 0e8893e1ba
git*: refresh pages (#16372)
Co-authored-by: Juri Dispan <juri.dispan@posteo.net>
Co-authored-by: CleanMachine1 <78213164+CleanMachine1@users.noreply.github.com>
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
2025-05-05 09:12:13 +03:00

781 B

git restore

Restore working tree files. Requires Git version 2.23+. See also git checkout and git reset. More information: https://git-scm.com/docs/git-restore.

  • Restore an unstaged file to the staged version:

git restore {{path/to/file}}

  • Restore an unstaged file to the version of a specific commit:

git restore {{[-s|--source]}} {{commit}} {{path/to/file}}

  • Discard all unstaged changes to tracked files:

git restore :/

  • Unstage a file:

git restore {{[-S|--staged]}} {{path/to/file}}

  • Unstage all files:

git restore {{[-S|--staged]}} :/

  • Discard all changes to files, both staged and unstaged:

git restore {{[-W|--worktree]}} {{[-S|--staged]}} :/

  • Interactively select sections of files to restore:

git restore {{[-p|--patch]}}