Advanced Git
Amanda Crawford-Adamo
Software and Data Engineer
.git/logs/refs/heads/ directory
| Feature | Git Reflog | Git Log |
|---|---|---|
| Purpose | Shows reference updates and rewrites in local repo | Shows commit history only |
| Scope | Local repository only | Local and remote repositories |
| Content | All ref updates (commits, resets, merges, etc.) | Only commits |
| Persistence | Temporary (usually 90 days) | Permanent (part of repository history) |
| Use Case | Recovering lost commits, understanding recent actions | Viewing project history, understanding feature development |
git reflog
git reflog show
git reflog expire

| Component | Description |
|---|---|
| short-hash | Abbreviated commit hash |
| ref | Usually HEAD, but can be branch names |
| index | Position in the reflog (0 is the most recent) |
| action | Type of action (commit, reset, merge, etc) |
| descriptions | Description about the action |
since = show entries from this point in time
git reflog --since "time-qualifer"
until = show entries up to this point in time
git reflog --until "time-qualifer"
git reflog --since="1 week ago"
git reflog --until="yesterday"
git reflog --until="2024-01-01"
etl-featureHow can we restore the etl-feature branch?
git reflog
git checkout <hash>
git checkout -b <branch-name>
| Reset Type | Command | Effect on Working Directory | Effect on Staging Area |
|---|---|---|---|
| Soft | git reset --soft <commit> |
No changes | Changes remain staged |
| Mixed (Default) | git reset --mixed <commit> |
No changes | Changes are unstaged |
| Hard | git reset --hard <commit> |
Changes are discarded | Changes are discarded |
How do we revert back to the previous ETL script changes?
git reflog
git reset --soft HEAD@{1}
Reflog is our local time machine when we make mistakes

Advanced Git