From d157c1f373c92ce70df7455ac0ab151c47022639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20W=C3=BCnsche?= <42999314+thomaswuensche@users.noreply.github.com> Date: Thu, 7 Jan 2021 13:58:00 +0100 Subject: [PATCH] git-restore: add examples (#5101) * git-restore: add examples * update git-restore.md Co-authored-by: Starbeamrainbowlabs * update git-restore.md Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com> Co-authored-by: Starbeamrainbowlabs Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com> --- pages/common/git-restore.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/pages/common/git-restore.md b/pages/common/git-restore.md index c8b5e9b8e..44f3c0847 100644 --- a/pages/common/git-restore.md +++ b/pages/common/git-restore.md @@ -1,17 +1,33 @@ # git restore > Restore working tree files. Requires git version 2.23+. -> See also `git checkout`. +> See also `git checkout` and `git reset`. > More information: . -- Restore a deleted file from the contents of the current commit (HEAD): +- Restore an unstaged file to the version of the current commit (HEAD): `git restore {{path/to/file}}` -- Restore a file to a version from a different commit: +- Restore an unstaged file to the version of a specific commit: `git restore --source {{commit}} {{path/to/file}}` -- Undo any uncommitted changes to tracked files, reverting to the current HEAD: +- Discard all unstaged changes to tracked files: -`git restore .` +`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`