How to move a tracked file?

git mv file_name existing_directory

To move a file tracked by git use git mv file_name existing_directory. This command will move the file and add it to your staging area. You will still need to commit the changes with git commit.

Layer 1
Terminal Example
git mv image.png assets

git status
On branch main
Changes to be committed:
  (use "git restore --staged ..." to unstage)
    renamed:    image.png -> assets/image.png

See git mv to learn more about it.

Last modified on November 30, 2021.

You might also like