]> git.ipfire.org Git - thirdparty/git.git/blob - Documentation/git-reflog.txt
format-patch: fix leak of empty header string
[thirdparty/git.git] / Documentation / git-reflog.txt
1 git-reflog(1)
2 =============
3
4 NAME
5 ----
6 git-reflog - Manage reflog information
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git reflog' [show] [<log-options>] [<ref>]
13 'git reflog expire' [--expire=<time>] [--expire-unreachable=<time>]
14 [--rewrite] [--updateref] [--stale-fix]
15 [--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]
16 'git reflog delete' [--rewrite] [--updateref]
17 [--dry-run | -n] [--verbose] <ref>@{<specifier>}...
18 'git reflog exists' <ref>
19
20 DESCRIPTION
21 -----------
22 This command manages the information recorded in the reflogs.
23
24 Reference logs, or "reflogs", record when the tips of branches and
25 other references were updated in the local repository. Reflogs are
26 useful in various Git commands, to specify the old value of a
27 reference. For example, `HEAD@{2}` means "where HEAD used to be two
28 moves ago", `master@{one.week.ago}` means "where master used to point
29 to one week ago in this local repository", and so on. See
30 linkgit:gitrevisions[7] for more details.
31
32 The command takes various subcommands, and different options
33 depending on the subcommand:
34
35 The "show" subcommand (which is also the default, in the absence of
36 any subcommands) shows the log of the reference provided in the
37 command-line (or `HEAD`, by default). The reflog covers all recent
38 actions, and in addition the `HEAD` reflog records branch switching.
39 `git reflog show` is an alias for `git log -g --abbrev-commit
40 --pretty=oneline`; see linkgit:git-log[1] for more information.
41
42 The "expire" subcommand prunes older reflog entries. Entries older
43 than `expire` time, or entries older than `expire-unreachable` time
44 and not reachable from the current tip, are removed from the reflog.
45 This is typically not used directly by end users -- instead, see
46 linkgit:git-gc[1].
47
48 The "delete" subcommand deletes single entries from the reflog. Its
49 argument must be an _exact_ entry (e.g. "`git reflog delete
50 master@{2}`"). This subcommand is also typically not used directly by
51 end users.
52
53 The "exists" subcommand checks whether a ref has a reflog. It exits
54 with zero status if the reflog exists, and non-zero status if it does
55 not.
56
57 OPTIONS
58 -------
59
60 Options for `show`
61 ~~~~~~~~~~~~~~~~~~
62
63 `git reflog show` accepts any of the options accepted by `git log`.
64
65
66 Options for `expire`
67 ~~~~~~~~~~~~~~~~~~~~
68
69 --all::
70 Process the reflogs of all references.
71
72 --single-worktree::
73 By default when `--all` is specified, reflogs from all working
74 trees are processed. This option limits the processing to reflogs
75 from the current working tree only.
76
77 --expire=<time>::
78 Prune entries older than the specified time. If this option is
79 not specified, the expiration time is taken from the
80 configuration setting `gc.reflogExpire`, which in turn
81 defaults to 90 days. `--expire=all` prunes entries regardless
82 of their age; `--expire=never` turns off pruning of reachable
83 entries (but see `--expire-unreachable`).
84
85 --expire-unreachable=<time>::
86 Prune entries older than `<time>` that are not reachable from
87 the current tip of the branch. If this option is not
88 specified, the expiration time is taken from the configuration
89 setting `gc.reflogExpireUnreachable`, which in turn defaults
90 to 30 days. `--expire-unreachable=all` prunes unreachable
91 entries regardless of their age; `--expire-unreachable=never`
92 turns off early pruning of unreachable entries (but see
93 `--expire`).
94
95 --updateref::
96 Update the reference to the value of the top reflog entry (i.e.
97 <ref>@\{0\}) if the previous top entry was pruned. (This
98 option is ignored for symbolic references.)
99
100 --rewrite::
101 If a reflog entry's predecessor is pruned, adjust its "old"
102 SHA-1 to be equal to the "new" SHA-1 field of the entry that
103 now precedes it.
104
105 --stale-fix::
106 Prune any reflog entries that point to "broken commits". A
107 broken commit is a commit that is not reachable from any of
108 the reference tips and that refers, directly or indirectly, to
109 a missing commit, tree, or blob object.
110 +
111 This computation involves traversing all the reachable objects, i.e. it
112 has the same cost as 'git prune'. It is primarily intended to fix
113 corruption caused by garbage collecting using older versions of Git,
114 which didn't protect objects referred to by reflogs.
115
116 -n::
117 --dry-run::
118 Do not actually prune any entries; just show what would have
119 been pruned.
120
121 --verbose::
122 Print extra information on screen.
123
124
125 Options for `delete`
126 ~~~~~~~~~~~~~~~~~~~~
127
128 `git reflog delete` accepts options `--updateref`, `--rewrite`, `-n`,
129 `--dry-run`, and `--verbose`, with the same meanings as when they are
130 used with `expire`.
131
132
133 GIT
134 ---
135 Part of the linkgit:git[1] suite