Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 635 Bytes

File metadata and controls

28 lines (19 loc) · 635 Bytes

Rename or Remove files

Move or Rename File (Unix Command)

# Renaming
mv file1.txt file2.txt

# Moving
mv file1.txt src/file1.txt

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.

# Renameing
git mv file1.txt file2.txt

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