Skip to content

Latest commit

 

History

History

rename-or-move-files

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Rename or Remove files

Unix Command

# Renaming
mv file1.txt file2.txt

# Moving
mv file1.txt src/file1.txt

Git Command

Renaming and Moving a File will make 2 changes...(Let's say in above case)

  • Deleting file1.txt
  • Creating file2.txt OR src/file1.txt

Now, If we were to Rename or Move a File which is being tracked by Git, Then we'll have to stage both of the changes mentioned above.

Git provides us with a command that can do both, Renaming or Moving and Staging necessary changes.

# Renaming
git mv file1.txt file2.txt

# Moving
git mv file1.txt src/file2.txt