名称NAME
git-reset - 将当前HEAD重置为指定状态
概要SYNOPSIS
git reset [-q] [<tree-ish>] [--] <pathspec>…
git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]
git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>…]
git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
描述DESCRIPTION
在前三种形式中,将条目从<tree-ish>复制到索引中。 在最后一种形式中,将当前分支头(HEAD)设置为<commit>,可以选择修改索引和工作树以使其匹配。 <tree-ish>/<commit>在所有形式中均默认为HEAD。
git reset [-q] [<tree-ish>] [--] <pathspec>…
git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]
这些形式将所有与<pathspec>匹配的路径的索引条目重置为其在<tree-ish>的状态。 (它不会影响工作树或当前分支。)
这意味着git reset <pathspec>与git add <pathspec>相反。
此命令等效于git restore [--source = <tree-ish>] --staged <pathspec> ....
运行git reset <pathspec>更新索引条目后,可以使用git-restore [1]将索引中的内容检出到工作树中。 或者,使用git-restore [1]并使用--source指定一个提交commit,您可以一次性将路径内容从提交复制到索引和工作树中。
git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>…]
以交互的方式在索引和<tree-ish>之间的差异中选择块(默认为HEAD)。 所选的块被反向应用于索引。
这意味着git reset -p与git add -p相反,即您可以使用它选择性地重置块。 请参阅git-add [1]的“交互模式”部分,以了解如何操作--patchmode。
git reset [<mode>] [<commit>]
该形式表格将当前分支头重置为<commit>,并可能根据<mode>更新索引(将其重置为<commit>的树)和工作树。 如果省略<mode>,则默认为--mixed。
<mode>必须是以下之一:
- --soft
完全不接触索引文件或工作树(就像所有模式一样,将头重置为<commit>)。 这样,所有更改的文件都将保留“要提交的更改”,就像git status 一样。
- --mixed
重置索引但不重置工作树(即,已更改的文件将保留但未标记为提交),并报告尚未更新的内容。 这是默认操作。
If -N
is specified, removed paths are marked as intent-to-add (see git-add[1]).
- --hard
重置索引和工作树。 自<commit>以来,工作树中跟踪文件的任何更改都将被丢弃。
- --merge
重置索引并更新工作树中<commit>和HEAD之间不同的文件,但保留那些索引和工作树之间不同的文件(即具有未添加更改的文件)。 如果一个文件在<commit>之间不同,并且索引未进行暂存更改,则重置将中止。
In other words, --merge
does something like a git read-tree -u -m <commit>
, but carries forward unmerged index entries.
- --keep
重置索引条目并更新<commit>和HEAD之间不同的工作树中的文件。 如果<commit>和HEAD之间的文件存在本地更改,则重置将中止。
选项OPTIONS
-q
--quiet
--no-quiet
Be quiet, only report errors. The default behavior is set by the reset.quiet
config option. --quiet
and --no-quiet
will override the default behavior.
--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>…
限制受操作影响的路径。