Interview Prep/Git & GitHub/Lost Work, HEAD and History Problems

After renaming a file, `git log file` shows only the rename commit and the old history appears lost.

IntermediateTroubleshootingLost Work, HEAD and History Problems
Answer

Likely causes → Git has no rename tracking; git log <path> follows only the current path name unless told otherwise. Large edits plus the rename in one commit also defeat similarity detection.

Diagnose →

git log --follow --oneline -- new/path.py
git log --stat -M --diff-filter=R -3

Fix → Use git log --follow, and git blame -C -C to trace copied or moved code. On GitHub, the History button follows renames in the UI.

Prevent → Rename in a separate commit without editing contents.

All Git & GitHub questions Roadmap: Git & GitHub

More on Lost Work, HEAD and History Problems