GIT基本快照命令之git-restore

名称NAME

git-restore - 恢复工作树文件

概要SYNOPSIS

git restore [<options>] [--source=<tree>] [--staged] [--worktree] [--] <pathspec>…​
git restore [<options>] [--source=<tree>] [--staged] [--worktree] --pathspec-from-file=<file> [--pathspec-file-nul]
git restore (-p|--patch) [<options>] [--source=<tree>] [--staged] [--worktree] [--] [<pathspec>…​]

描述DESCRIPTION

从一个恢复源中的某些内容恢复工作树中的指定路径。 如果路径是被追踪的但在恢复源中不存在,则会将其删除以匹配该源。

该命令还可用于通过--staged还原索引中的内容,或通过--staged --worktree还原工作树和索引。

默认情况下,工作树和索引的还原源分别是索引index和HEAD。 --source可用于将提交指定为还原源。

有关这三个命令之间的区别,请参见git [1]中的“reset,restore和revert”。

选项OPTIONS

-s <tree>

--source=<tree>

使用给定树中的内容还原工作树文件。 通常通过命名与之关联的提交,分支或标签来指定源树。

如果未指定,则工作树的默认还原源是索引,索引的默认还原源是HEAD。 同时指定了--staged和--worktree时,还必须指定--source。

-p    --patch

交互性的选择在还原源和还原位置之间的差异的块。 请参阅git-add [1]的“交互模式”部分,以了解如何操作--patch模式。

Note that --patch can accept no pathspec and will prompt to restore all modified paths.

请注意,-patch可以接受没有pathspec,并且会提示您还原所有修改的路径。

-W

--worktree

-S

--staged

指定还原位置。 如果未指定任何选项,则默认情况下将还原工作树。 指定--staged将仅还原索引。 同时指定两者将同时恢复。

-q

--quiet

Quiet, suppress feedback messages. Implies --no-progress.

--progress

--no-progress

Progress status is reported on the standard error stream by default when it is attached to a terminal, unless --quiet is specified. This flag enables progress reporting even if not attached to a terminal, regardless of --quiet.

除非指定了--quiet,否则当附加到一个终端时,默认情况下,将在标准错误流上报告该进度状态。 即使未附加到终端,此标志也可以启用进度报告,而不管--quiet是什么。

--ours

--theirs

When restoring files in the working tree from the index, use stage #2 (ours) or #3 (theirs) for unmerged paths.

Note that during git rebase and git pull --rebaseours and theirs may appear swapped. See the explanation of the same options in git-checkout[1] for details.

-m

--merge

从索引还原工作树上的文件时,请在未合并的路径中重新创建冲突的合并。

--conflict=<style>

与上面的--merge选项相同,但是更改了显示冲突的块的方式,覆盖了merge.conflictStyle配置变量。 可能的值为“merge”(默认)和“ diff3”(除了“merge”样式显示的内容以外,还显示原始内容)。

--ignore-unmerged

When restoring files on the working tree from the index, do not abort the operation if there are unmerged entries and neither --ours--theirs--merge or --conflict is specified. Unmerged paths on the working tree are left alone.

--ignore-skip-worktree-bits

In sparse checkout mode, by default is to only update entries matched by <pathspec> and sparse patterns in $GIT_DIR/info/sparse-checkout. This option ignores the sparse patterns and unconditionally restores any files in <pathspec>.

--overlay

--no-overlay

In overlay mode, the command never removes files when restoring. In no-overlay mode, tracked files that do not appear in the --source tree are removed, to make them match <tree> exactly. The default is no-overlay mode.

--pathspec-from-file=<file>

Pathspec is passed in <file> instead of commandline args. If <file> is exactly - then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable core.quotePath (see git-config[1]). See also --pathspec-file-nul and global --literal-pathspecs.

--pathspec-file-nul

Only meaningful with --pathspec-from-file. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).

--

不要将其他参数解释为选项。

<pathspec>…​

限制受操作影响的路径。

发布了243 篇原创文章 · 获赞 138 · 访问量 138万+

猜你喜欢

转载自blog.csdn.net/ystyaoshengting/article/details/104068579