Why You Should Never Rename or Move Files!

A practical Git note on preserving history correctly when files are moved or renamed.

Jul 14, 2023 3 min read Originally published on Medium
  • git
  • version-control
  • developer-tooling
A file and folder themed illustration representing Git history

Originally published on Medium. This version is now archived under /blogs.

This is one of the earlier pieces in the archive, and it has been preserved here as a short self-hosted edition so the full blog can live under /blogs.

The core lesson still holds: Git tracks content, not your intentions. When a file is renamed or moved, history is only easy to follow when the change is kept clean and the file contents are not simultaneously rewritten beyond recognition.

The practical habit

If a file needs a new name or a new location, make that change separately from large refactors whenever you can. Smaller diffs make history easier to inspect, reduce confusion in code review, and make future archaeology dramatically less painful.

Why it matters

Engineers often discover this the hard way when trying to answer basic questions later: when was this introduced, why was it moved, and what existed before the current structure?

Keeping moves, renames, and substantive code edits distinct gives Git a much better chance of preserving understandable history for your future self and your teammates.

If you want the original publication context, the original Medium post is still available.