Moving and renaming files in Git

Moving and renaming files in Git

Users can move or rename files or directory in git. sometimes we need to change the file extensions or formats, this comes under renaming files .git mv command is used to do all these tasks.

Command to move the file to other directories

git mv /directory/

The above command moves the file to the required path in your machine

Command to change extensions

git mv file.c

if a user accidentally saved a c language file as a python file, user can able to rename extension by using mv

Command to rename directories

git mv /source/ /destnation/

the above command is used to rename an old folder to new folder

git mv command will not overwrite the file it the file already we should use force -f tag

Command to force move

git mv -f file.c

If the file named file.c already existed, then by using -f file.c is updated with contents from the

Last updated on by vishal devxo