git says “not under version control” for just-checked-out file

后端 未结 5 691
梦毁少年i
梦毁少年i 2021-02-08 19:37

I have the distinct impression my Git repo is somehow mangled.

Here\'s the sequence I\'m doing:

  1. git clone [remote\'s clone string]

    This creates,

5条回答
  •  我寻月下人不归
    2021-02-08 20:08

    Another quirk that left me frustrated is if you're using the command line, it will use your current path to git mv the file. So if you have a file in C:\Git\MyRepo\MyFolder\MyFile.txt

    If you do:

    c:

    cd git

    cd myrepo

    cd myfolder

    dir

    It will work fine, you'll see your file. But if you type git mv MyFile.txt MyFile2.txt you will get an error because git can't find Myfile.txt.

    The reason is that it's looking at your current path, which is c:\git\myrepo\myfolder\

    But git is case sensitive. So you have to go back and type

    c:

    cd Git

    cd MyRepo

    cd MyFolder

    If you then type git mv it will work fine.

    Putting this in as an answer for people like me that found this post while debugging this error message.

提交回复
热议问题