git-reflog
管理 reflog 信息。
概要
bash
git reflog [show] [<log-options>] [<ref>]
git reflog list
git reflog exists <ref>
git reflog write <ref> <old-oid> <new-oid> <message>
git reflog delete [--rewrite] [--updateref]
[--dry-run | -n] [--verbose] <ref>@{<specifier>}...
git reflog drop [--all [--single-worktree] | <refs>...]
git reflog expire [--expire=<time>] [--expire-unreachable=<time>]
[--rewrite] [--updateref] [--stale-fix]
[--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]描述
此命令管理记录在 reflog 中的信息。
引用日志(reflog)记录分支和其他引用的提示在本地仓库中何时被更新。reflog 在各种 Git 命令中非常有用,可用于指定引用的旧值。例如,HEAD@{2} 表示"HEAD 两次移动之前的位置",master@{one.week.ago} 表示"一周前在此本地仓库中 master 指向的位置",等等。有关更多详细信息,请参阅 gitrevisions(7)。
该命令接受各种子命令,以及根据子命令不同的选项:
- "show" 子命令(在没有任何子命令时也是默认值)显示命令行中提供的引用的日志(或默认为
HEAD)。reflog 涵盖所有最近的操作,此外HEADreflog 还记录分支切换。git reflog show是git log -g --abbrev-commit --pretty=oneline的别名。 - "list" 子命令列出所有具有对应 reflog 的引用。
- "exists" 子命令检查引用是否有 reflog。如果 reflog 存在则以零状态退出,否则以非零状态退出。
- "write" 子命令向给定引用的 reflog 写入单个条目。
- "delete" 子命令从 reflog 中删除单个条目,但不删除 reflog 本身。
- "drop" 子命令完全删除指定引用的 reflog。
- "expire" 子命令修剪较旧的 reflog 条目。
选项
show 的选项
git reflog show 接受 git log 接受的任何选项。
delete 的选项
git reflog delete 接受选项 --updateref、--rewrite、-n、--dry-run 和 --verbose,与 expire 使用时的含义相同。
drop 的选项
--all:从所有工作树中删除所有引用的 reflog。--single-worktree:默认情况下,当指定--all时,会删除所有工作树的 reflog。此选项将处理限制为仅当前工作树的 reflog。
expire 的选项
--all:处理所有引用的 reflog。--single-worktree:默认情况下,当指定--all时,会处理所有工作树的 reflog。此选项将处理限制为仅当前工作树的 reflog。--expire=<time>:修剪早于指定时间的条目。如果未指定此选项,则从配置设置gc.reflogExpire获取过期时间,默认为 90 天。--expire=all修剪所有条目;--expire=never关闭可达条目的修剪。--expire-unreachable=<time>:修剪早于<time>且从当前分支提示不可达的条目。如果未指定此选项,则从配置设置gc.reflogExpireUnreachable获取过期时间,默认为 30 天。--updateref:如果先前的顶部条目被修剪,则将引用更新为顶部 reflog 条目的值。--rewrite:如果 reflog 条目的前身被修剪,则将其"旧"SHA-1 调整为等于现在位于其之前的条目的"新"SHA-1 字段。--stale-fix:修剪任何指向"损坏提交"的 reflog 条目。-n, --dry-run:不实际修剪任何条目;只显示将被修剪的内容。--verbose:在屏幕上打印额外信息。
Git
git 套件的一部分
