How to rename a tracked file?
git mv old_name new_name
To rename a file tracked by git use git mv old_name new_name
. This command will rename the file and add it to your staging area. You will still need to commit the changes with git commit
.
git mv image.png icon.png
git status
On branch main
Changes to be committed:
(use "git restore --staged..." to unstage)
renamed: image.png -> icon.png
See git mv to learn more about it.