How to make git mark a deleted and a new file as a file move?

Git will automatically detect the move/rename if your modification is not too severe. Just git add the new file, and git rm the old file. git status will then show whether it has detected the rename.

additionally, for moves around directories, you may need to:

  1. cd to the top of that directory structure.
  2. Run git add -A .
  3. Run git status to verify that the “new file” is now a “renamed” file

If git status still shows “new file” and not “renamed” you need to follow Hank Gay’s advice and do the move and modify in two separate commits.

Leave a Comment