I’ve moved a file manually and then I’ve modified it. According to Git, it is a new file and a removed file. Is there any way to force Git into treating it as a file move?

15 s
15

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.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *