Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
- 2.50.1 no changes
-
2.50.0
2025-06-16
- 2.45.1 → 2.49.1 no changes
-
2.45.0
2024-04-29
- 2.39.1 → 2.44.4 no changes
-
2.39.0
2022-12-12
- 2.37.4 → 2.38.5 no changes
-
2.37.3
2022-08-30
- 2.35.1 → 2.37.2 no changes
-
2.35.0
2022-01-24
- 2.20.1 → 2.34.8 no changes
-
2.20.0
2018-12-09
- 2.17.0 → 2.19.6 no changes
-
2.16.6
2019-12-06
- 2.7.6 → 2.15.4 no changes
-
2.6.7
2017-05-05
- 2.5.6 no changes
-
2.4.12
2017-05-05
- 2.1.4 → 2.3.10 no changes
-
2.0.5
2014-12-17
概述
git reflog [show] [<log-options>] [<ref>] git reflog list git reflog expire [--expire=<time>] [--expire-unreachable=<time>] [--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] [--verbose] [--all [--single-worktree] | <ref>…] git reflog delete [--rewrite] [--updateref] [--dry-run | -n] [--verbose] <ref>@{<specifier>}… git reflog drop [--all [--single-worktree] | <ref>…] git reflog exists <ref>
描述
该命令管理记录在引用日志中的信息。
引用日志(或称 "reflogs")记录了本地仓库中分支和其他引用的提示更新时间。参考日志在各种 Git 命令中都很有用,可以用来指定引用的旧值。例如,HEAD@{2}
表示 “两步前 HEAD 所在的位置”,master@{one.week.ago}
表示 “一周前本仓库中 master 所在的位置”,等等。详见 gitrevisions[7]。
该命令采取不同的子命令,并根据子命令有不同的选项:
"show" 子命令(也是默认命令,在没有任何子命令的情况下)显示命令行中提供的引用日志(或默认的 HEAD
)。引用日志包括所有最近的操作,此外,HEAD
引用日志还记录分支切换。 git reflog show
是 git log -g --abbrev-commit --pretty=oneline
的别名;详见 git-log[1]。
"list" 子命令列出了所有具有相应引用日志的引用。
"expire" 子命令用于删除旧的引用日志条目。超过 expire
时间的条目,或超过 expire-unreachable
时间且当前 tip 无法访问的条目,都会从引用日志中删除。 终端用户通常不会直接使用该子项,请参见 git-gc[1]。
The "delete" subcommand deletes single entries from the reflog, but not the reflog itself. Its argument must be an exact entry (e.g. "git reflog delete master@{2}
"). This subcommand is also typically not used directly by end users.
The "drop" subcommand completely removes the reflog for the specified references. This is in contrast to "expire" and "delete", both of which can be used to delete reflog entries, but not the reflog itself.
"exists" 子命令检查引用是否有引用日志。 如果引用日志存在,则以零状态退出;如果不存在,则以非零状态退出。
选项
expire
的选项
- --all
-
处理所有引用的引用日志。
- --single-worktree
-
默认情况下,如果指定了 `--all`选项,所有工作区的引用日志都会被处理。此选项限制只处理当前工作区的引用日志。
- --expire=<时间>
-
剪除超过指定时间的条目。如果未指定此选项,则过期时间取自配置设置
gc.reflogExpire
,默认为 90 天。--expire=all
会剪除任何年龄的条目;--expire=never
会关闭剪除可到达条目的功能(但请参阅--expire-unreachable
)。 - --expire-unreachable=<时间>
-
剪除从分支当前顶端无法到达的超过
<时间>
的条目。如果未指定此选项,则过期时间取自配置设置gc.reflogExpireUnreachable
,默认为 30 天。--expire-unreachable=all
会修剪无法访问的条目,无论其年龄大小;--expire-unreachable=never
会关闭对无法访问条目的早期修剪(但请参见--expire
)。 - --updateref
-
如果前一个顶层条目已被剪枝,则将引用更新为顶层引用日志条目的值(即 <引用>@{0})。 (符号引用将忽略此选项)
- --rewrite
-
如果重写日志条目的前一个条目被剪枝,则调整其 “旧” SHA-1,使其等于现在排在其前面的条目的 “新” SHA-1 字段。
- --stale-fix
-
删除任何指向 “中断提交” 的引用日志条目。中断提交是指从任何引用提示都无法到达的提交,它直接或间接地指向丢失的提交、树或二进制对象。
这种计算涉及遍历所有可到达的对象,也就是说,其代价与 git prune 相同。 它的主要目的是修复旧版本 Git 垃圾回收所造成的损坏,因为旧版本的 Git 无法保护引用日志所引用的对象。
- -n
- --dry-run
-
不要实际修剪任何条目,只需显示本应修剪的内容。
- --verbose
-
在屏幕上打印额外信息。
GIT
属于 git[1] 文档