'\" t .\" Title: git-restore .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 2025-03-14 .\" Manual: Git Manual .\" Source: Git 2.49.0 .\" Language: English .\" .TH "GIT\-RESTORE" "1" "2025\-03\-14" "Git 2\&.49\&.0" "Git Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" git-restore \- Restore working tree files .SH "SYNOPSIS" .sp .nf \fBgit\fR \fBrestore\fR [\fI\fR] [\fB\-\-source=\fR\fI\fR] [\fB\-\-staged\fR] [\fB\-\-worktree\fR] [\fB\-\-\fR] \fI\fR\&... \fBgit\fR \fBrestore\fR [\fI\fR] [\fB\-\-source=\fR\fI\fR] [\fB\-\-staged\fR] [\fB\-\-worktree\fR] \fB\-\-pathspec\-from\-file=\fR\fI\fR [\fB\-\-pathspec\-file\-nul\fR] \fBgit\fR \fBrestore\fR (\fB\-p\fR|\fB\-\-patch\fR) [\fI\fR] [\fB\-\-source=\fR\fI\fR] [\fB\-\-staged\fR] [\fB\-\-worktree\fR] [\fB\-\-\fR] [\fI\fR\&...] .fi .sp .SH "DESCRIPTION" .sp Restore specified paths in the working tree with some contents from a restore source\&. If a path is tracked but does not exist in the restore source, it will be removed to match the source\&. .sp The command can also be used to restore the content in the index with \fB\-\-staged\fR, or restore both the working tree and the index with \fB\-\-staged\fR \fB\-\-worktree\fR\&. .sp By default, if \fB\-\-staged\fR is given, the contents are restored from \fBHEAD\fR, otherwise from the index\&. Use \fB\-\-source\fR to restore from a different commit\&. .sp See "Reset, restore and revert" in \fBgit\fR(1) for the differences between the three commands\&. .sp THIS COMMAND IS EXPERIMENTAL\&. THE BEHAVIOR MAY CHANGE\&. .SH "OPTIONS" .PP \fB\-s\fR \fI\fR, \fB\-\-source=\fR\fI\fR .RS 4 Restore the working tree files with the content from the given tree\&. It is common to specify the source tree by naming a commit, branch or tag associated with it\&. .sp If not specified, the contents are restored from \fBHEAD\fR if \fB\-\-staged\fR is given, otherwise from the index\&. .sp As a special case, you may use "\fI\fR\fB\&.\&.\&.\fR\fI\fR" as a shortcut for the merge base of \fI\fR and \fI\fR if there is exactly one merge base\&. You can leave out at most one of \fI_\fR and \fI\fR, in which case it defaults to \fBHEAD\fR\&. .RE .PP \fB\-p\fR, \fB\-\-patch\fR .RS 4 Interactively select hunks in the difference between the restore source and the restore location\&. See the "Interactive Mode" section of \fBgit-add\fR(1) to learn how to operate the \fB\-\-patch\fR mode\&. .sp Note that \fB\-\-patch\fR can accept no pathspec and will prompt to restore all modified paths\&. .RE .PP \fB\-W\fR, \fB\-\-worktree\fR, \fB\-S\fR, \fB\-\-staged\fR .RS 4 Specify the restore location\&. If neither option is specified, by default the working tree is restored\&. Specifying \fB\-\-staged\fR will only restore the index\&. Specifying both restores both\&. .RE .PP \fB\-q\fR, \fB\-\-quiet\fR .RS 4 Quiet, suppress feedback messages\&. Implies \fB\-\-no\-progress\fR\&. .RE .PP \fB\-\-progress\fR, \fB\-\-no\-progress\fR .RS 4 Progress status is reported on the standard error stream by default when it is attached to a terminal, unless \fB\-\-quiet\fR is specified\&. This flag enables progress reporting even if not attached to a terminal, regardless of \fB\-\-quiet\fR\&. .RE .PP \fB\-\-ours\fR, \fB\-\-theirs\fR .RS 4 When restoring files in the working tree from the index, use stage #2 (\fBours\fR) or #3 (\fBtheirs\fR) for unmerged paths\&. This option cannot be used when checking out paths from a tree\-ish (i\&.e\&. with the \fB\-\-source\fR option)\&. .sp Note that during \fBgit\fR \fBrebase\fR and \fBgit\fR \fBpull\fR \fB\-\-rebase\fR, \fBours\fR and \fBtheirs\fR may appear swapped\&. See the explanation of the same options in \fBgit-checkout\fR(1) for details\&. .RE .PP \fB\-m\fR, \fB\-\-merge\fR .RS 4 When restoring files on the working tree from the index, recreate the conflicted merge in the unmerged paths\&. This option cannot be used when checking out paths from a tree\-ish (i\&.e\&. with the \fB\-\-source\fR option)\&. .RE .PP \fB\-\-conflict=\fR\fI