Is there any way in VS Code to change a file's name so that the file history is preserved in git, and it doesn't think the tracked file's been deleted?
I'm hoping for a GUI implementation of the command:
git mv oldName.abc newName.xyz
Thanks
There is no need for it. Just rename the file. Git will detect renames regardless of whether git mv
was used or not.
Try it: rename it in the normal way and then do git status
. You will see two unstaged changes, one delete (D) and one add (M) - but that's only temporary. Stage both changes (using git add old_name new_name
or just git add .
), run git status
again and notice it now shows up as rename (R) and not as creation and deletion, so history is always preserved.
You may think there is a difference if you run git status
after manually renaming a file, but that only appears so because git mv
auto-stages the change (only after which it appears as rename). If you manually rename a file and then manually stage those changes, you get the same result!