blob: db9d46edfa950e8107f54b4f61dda5115d5c07e4 [file] [log] [blame]
Junio C Hamano74640642006-12-27 10:59:551git-reflog(1)
2=============
3
4NAME
5----
6git-reflog - Manage reflog information
7
8
9SYNOPSIS
10--------
Junio C Hamano15567bc2011-07-23 00:51:5911[verse]
Junio C Hamanod3339982007-02-09 08:38:4812'git reflog' <subcommand> <options>
Junio C Hamano74640642006-12-27 10:59:5513
14DESCRIPTION
15-----------
Junio C Hamanod3339982007-02-09 08:38:4816The command takes various subcommands, and different options
17depending on the subcommand:
18
19[verse]
Junio C Hamano59a32b02021-12-10 22:53:3820'git reflog' ['show'] [<log-options>] [<ref>]
Junio C Hamano185e7182015-03-10 23:05:5821'git reflog expire' [--expire=<time>] [--expire-unreachable=<time>]
22[--rewrite] [--updateref] [--stale-fix]
Junio C Hamano06ce83b2018-11-13 14:06:1223[--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]
Junio C Hamano185e7182015-03-10 23:05:5824'git reflog delete' [--rewrite] [--updateref]
Junio C Hamano472c81a2022-08-12 21:07:1025[--dry-run | -n] [--verbose] <ref>@{<specifier>}...
Junio C Hamanod7ed4042015-08-03 19:43:0026'git reflog exists' <ref>
Junio C Hamano74640642006-12-27 10:59:5527
Junio C Hamano185e7182015-03-10 23:05:5828Reference logs, or "reflogs", record when the tips of branches and
29other references were updated in the local repository. Reflogs are
30useful in various Git commands, to specify the old value of a
31reference. For example, `HEAD@{2}` means "where HEAD used to be two
32moves ago", `master@{one.week.ago}` means "where master used to point
33to one week ago in this local repository", and so on. See
34linkgit:gitrevisions[7] for more details.
Junio C Hamano74640642006-12-27 10:59:5535
Junio C Hamano185e7182015-03-10 23:05:5836This command manages the information recorded in the reflogs.
Junio C Hamano74640642006-12-27 10:59:5537
Junio C Hamano185e7182015-03-10 23:05:5838The "show" subcommand (which is also the default, in the absence of
39any subcommands) shows the log of the reference provided in the
40command-line (or `HEAD`, by default). The reflog covers all recent
41actions, and in addition the `HEAD` reflog records branch switching.
42`git reflog show` is an alias for `git log -g --abbrev-commit
43--pretty=oneline`; see linkgit:git-log[1] for more information.
Junio C Hamano2e72a942007-11-21 08:54:4244
Junio C Hamano185e7182015-03-10 23:05:5845The "expire" subcommand prunes older reflog entries. Entries older
46than `expire` time, or entries older than `expire-unreachable` time
47and not reachable from the current tip, are removed from the reflog.
48This is typically not used directly by end users -- instead, see
49linkgit:git-gc[1].
Junio C Hamano74640642006-12-27 10:59:5550
Junio C Hamano185e7182015-03-10 23:05:5851The "delete" subcommand deletes single entries from the reflog. Its
52argument must be an _exact_ entry (e.g. "`git reflog delete
53master@{2}`"). This subcommand is also typically not used directly by
54end users.
Junio C Hamano86bcccc2008-03-08 09:33:5555
Junio C Hamanod7ed4042015-08-03 19:43:0056The "exists" subcommand checks whether a ref has a reflog. It exits
57with zero status if the reflog exists, and non-zero status if it does
58not.
Junio C Hamano74640642006-12-27 10:59:5559
60OPTIONS
61-------
62
Junio C Hamano185e7182015-03-10 23:05:5863Options for `show`
64~~~~~~~~~~~~~~~~~~
Junio C Hamanoee695f22007-06-21 00:35:3665
Junio C Hamano185e7182015-03-10 23:05:5866`git reflog show` accepts any of the options accepted by `git log`.
Junio C Hamano74640642006-12-27 10:59:5567
Junio C Hamano185e7182015-03-10 23:05:5868
69Options for `expire`
70~~~~~~~~~~~~~~~~~~~~
Junio C Hamano74640642006-12-27 10:59:5571
72--all::
Junio C Hamano185e7182015-03-10 23:05:5873Process the reflogs of all references.
74
Junio C Hamano06ce83b2018-11-13 14:06:1275--single-worktree::
76By default when `--all` is specified, reflogs from all working
77trees are processed. This option limits the processing to reflogs
78from the current working tree only.
79
Junio C Hamano185e7182015-03-10 23:05:5880--expire=<time>::
81Prune entries older than the specified time. If this option is
82not specified, the expiration time is taken from the
83configuration setting `gc.reflogExpire`, which in turn
84defaults to 90 days. `--expire=all` prunes entries regardless
85of their age; `--expire=never` turns off pruning of reachable
86entries (but see `--expire-unreachable`).
87
88--expire-unreachable=<time>::
89Prune entries older than `<time>` that are not reachable from
90the current tip of the branch. If this option is not
91specified, the expiration time is taken from the configuration
92setting `gc.reflogExpireUnreachable`, which in turn defaults
93to 30 days. `--expire-unreachable=all` prunes unreachable
94entries regardless of their age; `--expire-unreachable=never`
95turns off early pruning of unreachable entries (but see
96`--expire`).
Junio C Hamano74640642006-12-27 10:59:5597
Junio C Hamano86bcccc2008-03-08 09:33:5598--updateref::
Junio C Hamano185e7182015-03-10 23:05:5899Update the reference to the value of the top reflog entry (i.e.
100<ref>@\{0\}) if the previous top entry was pruned. (This
101option is ignored for symbolic references.)
Junio C Hamano86bcccc2008-03-08 09:33:55102
103--rewrite::
Junio C Hamano185e7182015-03-10 23:05:58104If a reflog entry's predecessor is pruned, adjust its "old"
105SHA-1 to be equal to the "new" SHA-1 field of the entry that
106now precedes it.
107
108--stale-fix::
109Prune any reflog entries that point to "broken commits". A
110broken commit is a commit that is not reachable from any of
111the reference tips and that refers, directly or indirectly, to
112a missing commit, tree, or blob object.
113+
114This computation involves traversing all the reachable objects, i.e. it
115has the same cost as 'git prune'. It is primarily intended to fix
116corruption caused by garbage collecting using older versions of Git,
117which didn't protect objects referred to by reflogs.
118
119-n::
120--dry-run::
121Do not actually prune any entries; just show what would have
122been pruned.
Junio C Hamano86bcccc2008-03-08 09:33:55123
Junio C Hamano764a6672007-10-23 01:23:31124--verbose::
125Print extra information on screen.
126
Junio C Hamano185e7182015-03-10 23:05:58127
128Options for `delete`
129~~~~~~~~~~~~~~~~~~~~
130
131`git reflog delete` accepts options `--updateref`, `--rewrite`, `-n`,
132`--dry-run`, and `--verbose`, with the same meanings as when they are
133used with `expire`.
134
135
Junio C Hamano74640642006-12-27 10:59:55136GIT
137---
Junio C Hamanof7c042d2008-06-06 22:50:53138Part of the linkgit:git[1] suite