A common scenario while working with configuration management tools such as git is to rename existing files and
directories.
If you just rename an existing file or directory then git will not be aware of this change.You need to inform git of this
change.To instruct git that you want to rename a file or directory you can use the git mv command.
We use the git mv command as:
git mv CurrentFileName NewFileName
Suppose you have an existing file called File.txt and you want to rename it to File1.txt then you can use the git mv
command as:
$ git mv File.txt File1.txt
In the following git repository there is a single file called Test Document.txt
To rename the Test Document.txt to New Document.txt we execute the command
git mv “Test Document.txt” “New Document.txt”
Now if we list the files in the git repository we can see that the file Test Document.txt has been renamed to New Document.txt
$ git ls-files
New Documemt.txt
Leave a Reply