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