SYNOPSIS

git reflog [show] [<log-options>] [<ref>]
git reflog list
git reflog exists <ref>
git reflog write <ref> <old-oid> <new-oid> <message>
git reflog delete [--rewrite] [--updateref]
        [--dry-run | -n] [--verbose] <ref>@{<specifier>}...
git reflog drop [--all [--single-worktree] | <refs>...]
git reflog expire [--expire=<time>] [--expire-unreachable=<time>]
        [--rewrite] [--updateref] [--stale-fix]
        [--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]

DESCRIPTION

このコマンドは、reflogに記録された情報を管理します。

参照ログ(reference logs)、または "reflogs" は、ブランチのヒントやその他の参照がローカルリポジトリで更新された時期を記録します。reflogは、参照の古い値を指定するために、さまざまなGitコマンドで役立ちます。 たとえば、 HEAD@{2} は「HEADが2移動前にあった位置」を意味し、 master@{one.week.ago} は「masterがこのローカルリポジトリで1週間前を指していた位置」を意味する等々。詳細については gitrevisions(7) を参照してください。

このコマンドは、さまざまなサブコマンドと、サブコマンドに応じて異なるオプションを取ります:

「show」サブコマンド(サブコマンドの指定がない場合のデフォルトでもあります)は、コマンドライン(またはデフォルトでは「HEAD」)で指定される参照のログを表示します。 reflogは最近のすべてのアクションをカバーし、さらに HEAD reflogはブランチの切り替えを記録します。 git reflog showgit log -g --abbrev-commit --pretty=oneline のエイリアスです。詳細については git-log(1) を参照してください。

「list」サブコマンドは、 対応する reflog を持つすべての ref を一覧表示します。

「exists」サブコマンドは、refにreflogがあるかどうかをチェックします。reflogが存在する場合はゼロのステータスで終了し、存在しない場合はゼロ以外のステータスで終了します。

The "write" subcommand writes a single entry to the reflog of a given reference. This new entry is appended to the reflog and will thus become the most recent entry. The reference name must be fully qualified. Both the old and new object IDs must not be abbreviated and must point to existing objects. The reflog message gets normalized.

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.

「expire」サブコマンドは、古いreflogエントリを刈り取ります。「expire」時間より古いエントリ、または「expire-unreachable」時間より古く、現在の先端から到達できないエントリがreflogから削除されます。これは通常、エンドユーザーが直接使用することはありません。代わりに、 git-gc(1) を参照してください。

OPTIONS

showサブコマンド用オプション

git reflog show は、 git log で受け入れられるすべてのオプションを受け入れます。

deleteサブコマンド用オプション

git reflog delete は、オプション --updateref--rewrite-n--dry-run--verbose を受け入れます。これらは、 expire で使用される場合と同じ意味です。

Options for drop

--all

Drop the reflogs of all references from all worktrees.

--single-worktree

By default when --all is specified, reflogs from all working trees are dropped. This option limits the processing to reflogs from the current working tree only.

expireサブコマンド用オプション

--all

すべての参照のreflogを処理します。

--single-worktree

デフォルトでは、 --all が指定されている場合、すべての作業ツリーからのreflogが処理されます。 このオプションは、処理を現在の作業ツリー(cureent working tree)からのreflogのみに制限します。

--expire=<time>

指定された時間より古いエントリを刈り取ります。このオプションが指定されていない場合、有効期限は構成設定 gc.reflogExpire から取得され、デフォルトで90日になります。 --expire=all は、年齢に関係なくエントリを削除します。 --expire=never は、到達可能なエントリの刈り取りをオフにします(ただし、 --expire-unreachable も参照してください)。

--expire-unreachable=<time>

ブランチの現在の先端から到達できない <time> より古いエントリを刈り取ります。このオプションが指定されていない場合、有効期限は構成設定 gc.reflogExpireUnreachable から取得され、デフォルトで30日になります。 --expire-unreachable=all は、年齢に関係なく、到達不能なエントリを刈り取ります。 --expire-unreachable=never は、到達不能なエントリの早期刈り取りをオフにします(ただし、 --expire も参照してください)。

--updateref

以前の最上位エントリが刈り取りされた場合は、最上位のreflogエントリの値(つまり、 <ref>@{0} )への参照を更新します。(このオプションは、シンボリック参照では無視されます。)

--rewrite

reflogエントリーの前任者が刈り込まれてしまった場合、その「古い」SHA-1を、現在の前任者にあるエントリーの「新しい」SHA-1フィールドと等しくなるように調整します。

--stale-fix

「壊れたコミット」(broken commits)を指すreflogエントリを削除します。壊れたコミットとは、どのリファレンスヒントからも到達できず、直接または間接的に、欠落しているコミットまたはツリーまたはブロブオブジェクトを参照するコミットです。

これの計算では、到達可能なすべてのオブジェクトのトラバースが含まれます。つまり、 git prune と同じコストがかかります。これは主に、reflogによって参照されるオブジェクトを保護しなかった古いバージョンのGitを使用したガベージコレクションによって引き起こされた破損を修正することを目的としています。

-n
--dry-run

実際にエントリの刈り取りは行いません。何が刈り取られるかを表示するだけです。

--verbose

画面に追加情報を出力します。

GIT

Part of the git(1) suite