1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/git-restore.md
Edgar Handal 204b201918
git-restore: fix default to restore from staging (#15914)
By default, "git restore" restores from the index, not from HEAD.
2025-03-11 06:50:27 +02:00

33 lines
727 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 staged version:
`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`