1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-19 03:35:25 +02:00
tldr/pages/common/git-restore.md
Thomas Wünsche d157c1f373
git-restore: add examples (#5101)
* git-restore: add examples

* update git-restore.md

Co-authored-by: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>

* update git-restore.md

Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>

Co-authored-by: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
2021-01-07 07:58:00 -05:00

33 lines
750 B
Markdown

# 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 version of the current commit (HEAD):
`git restore {{path/to/file}}`
- Restore an unstaged file to the version of a specific commit:
`git restore --source {{commit}} {{path/to/file}}`
- Discard all unstaged changes to tracked files:
`git restore :/`
- Unstage a file:
`git restore --staged {{path/to/file}}`
- Unstage all files:
`git restore --staged :/`
- Discard all changes to files, both staged and unstaged:
`git restore --worktree --staged :/`
- Interactively select sections of files to restore:
`git restore --patch`