高度な Git
Amanda Crawford-Adamo
Software and Data Engineer
.git/logs/refs/heads/ に保存
| 機能 | Git Reflog | Git Log |
|---|---|---|
| 目的 | ローカルでの参照更新・書き換えを表示 | コミット履歴のみを表示 |
| 範囲 | ローカルリポジトリのみ | ローカルとリモート |
| 内容 | すべての参照更新(commit, reset, merge など) | コミットのみ |
| 永続性 | 一時的(通常 90 日) | 永続(履歴の一部) |
| 用途 | 失われたコミットの復旧、直近の操作の把握 | プロジェクト履歴や機能開発の把握 |
git reflog
git reflog show
git reflog expire

| コンポーネント | 説明 |
|---|---|
| short-hash | 省略したコミットハッシュ |
| ref | 通常は HEAD、ブランチ名の場合もある |
| index | Reflog 内の位置(0 が最新) |
| action | 操作の種類(commit, reset, merge など) |
| descriptions | 操作の説明 |
since = この時点以降の履歴を表示
git reflog --since "time-qualifer"
until = この時点までの履歴を表示
git reflog --until "time-qualifer"
git reflog --since="1 week ago"
git reflog --until="yesterday"
git reflog --until="2024-01-01"
etl-feature というブランチを作成etl-feature ブランチをどう復元する?
git reflog
git checkout <hash>
git checkout -b <branch-name>
| Reset 種別 | コマンド | 作業ツリーへの影響 | ステージへの影響 |
|---|---|---|---|
| Soft | git reset --soft <commit> |
変更なし | 変更はステージ済みのまま |
| Mixed (既定) | git reset --mixed <commit> |
変更なし | 変更はステージ解除 |
| Hard | git reset --hard <commit> |
変更を破棄 | 変更を破棄 |
直前の ETL スクリプト変更にどう戻す?
git reflog
git reset --soft HEAD@{1}
ミスをしたとき、Reflog はローカルのタイムマシンです

高度な Git