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