Back to all tips

Git Noob Tips

Rename or Move a File

🗓️ Published: 4/29/2022

Git usually gets confused when you rename/move a file and change its content at the same time. Git would think the old file was deleted and a new file was created. All of the version history is simply lost.

To prevent such things from happening, one should rename or move, using git:

git mv <src> <dest>

Instead of doing:

mv <src> <dest>

Discuss this tip on