Interview Prep/Git & GitHub/Commits, branches and tags

How do you move or rename files so Git tracks it cleanly?

IntermediateConceptCommits, branches and tags
Answer

Use git mv old new, which is just mv plus staging both sides. Git infers the rename at diff time, so renaming a file and heavily editing it in one commit can break rename detection and hurt blame/history. Do the pure rename in its own commit.

git mv src/util.py src/helpers.py
git commit -m "refactor: rename util to helpers"
All Git & GitHub questions Roadmap: Git & GitHub

More on Commits, branches and tags