Git mv error - fatal: not under version control

Hello. I’m having trouble getting the mv command to work in git bash. I have two text files, “MoveMe.txt” and “MoveMeX.txt”. I want to move the MoveMe.txt from the current directory to the NewFolder01 directory. I also want to move and rename the MoveMeX.txt file to NewFolder01. However, I keep getting the same error:

User@DESKTOP-CVJC14D MINGW64 ~/Desktop/SamsGitRepository (master)
$ mkdir NewFolder01
User@DESKTOP-CVJC14D MINGW64 ~/Desktop/SamsGitRepository (master)
$ git mv MoveMe NewFolder01/MoveMe
fatal: not under version control, source=MoveMe, destination=NewFolder01/MoveMe

User@DESKTOP-CVJC14D MINGW64 ~/Desktop/SamsGitRepository (master)
$ git mv MoveMeX NewFolder01/MoveMeRenamed
fatal: not under version control, source=MoveMeX, destination=NewFolder01/MoveMeRenamed

User@DESKTOP-CVJC14D MINGW64 ~/Desktop/SamsGitRepository (master)
$ pwd /c/Users/User/Desktop/SamsGitRepository

User@DESKTOP-CVJC14D MINGW64 ~/Desktop/SamsGitRepository (master)
$ git mv /c/Users/User/Desktop/SamsGitRepository/MoveMe /c/Users/User/Desktop/SamsGitRepository/NewFolder01/MoveMe
fatal: not under version control, source=MoveMe, destination=NewFolder01/MoveMe

I also want to mention that I have successfully been getting many other commands to work, but all of them generated this warning:

warning: CRLF will be replaced by LF in Third_html_renamed. The file will have its original line endings in your working directory

Just in case that might have something to do with my error?

Hello @RedSkeleton007,
Sorry for delayed and incomplete solution !!

This warning is appearing as you haven’t configured Git to properly handle line endings.
To solve the issue you need to execute the below command:

$ git config --global core.autocrlf false

You are not able to move the file as Moveme.txt file is not added in Git repository.
To solve the issue you need to first add the file using below command and then execute the git mv command:
$ git add MoveMe.txt

Please do let me know if you face issue again.

Thanks

1 Like