开发者

I change the capitalization of a directory and Git doesn't seem to pick up on it

I'm developing a project on OS X Lion that is under Git version control. I had these lowercase directories and then later capitalized them (e.g开发者_如何学C. emailaddresses => EmailAddresses), but Git doesn't seem to recognize the change. It still thinks the directories are lowercase when I run git ls-files and other commands.

Is this harmless, or should I do something else to get Git to pick up on this change?


You can tell git to take account of the case by running

git config core.ignorecase false


You're probably using case insensitive (but case preserving) HFS+. I usually work round this like so:

$ git mv somename tmpname
$ git mv tmpname SomeName


How to git mv on Mac Case-Sensitively

This is happening because Mac OS X implements case preserving and case insensitivity features that are intended to help you.

Although the double rename suggestions in the other answer will work, I recommend the use of '--force' for a best practice result:

$ git mv --force somename SomeName


Note: if you try without the force option, git will barf on you like this:

$ git mv somename SomeName
$ fatal: destination exists, source=somename, destination=SomeName

In the above example, the git command fails and no files are changed in the filesystem or in git's index.


Try to change git config option core.ignorecase to false in your .gitconfig file.


The following steps helped me resolve the issue:

  1. Rename the folder to temp:

    mv Folder temp                  // It will rename your Folder to temp
    
  2. Stage and commit:

    git add .
    git commit -m "Temp"
    
  3. Rename temp folder to your choice:

    mv temp folder        // It will rename temp folder to the name of your choice(folder)
    git add .
    git commit -m "Folder Fixed"
    

Done - You can now push.


The reason for this is that LINUX-based OS or macOS ignore case sensitive for file/folder name. We need to resolve this problem by the below steps

For Exp, you want to change folder name from Base to base
1. mv Base base2
2. git add . && git commit -m "Fix folder name problem (wip)"
3. mv base2 base
4. git add . && git commit -m "Fixed folder name problem"


If you do git mv AAA aaa or git mv -f AAA aaa, it will not be work and you will have error fatal: renaming 'AAA' failed: Invalid argument.

Because AAA and aaa are ONE SAME folder/file on case-insensitive file systems, move AAA to aaa means move AAA as aaa/AAA.

So you should do

git mv AAA aaa.1
git mv aaa.1 aaa

I hope it will be helpful for you.


None of these actually helped me, I still was having git tell me to stash my changes, because my situation was that my local folder was capitalised but the remote not, and my branch was behind and I could no longer pull because of file capitalization differences in the folder structure.

The only way I could fix this was deleting my local branch and checking out the remote.


You can also do this manually without using GIT commands. Inside the .git folder, simply delete the folder with the name you want i.e SomeName . And then rename the folder somename to SomeName. More details at : How to fix folder name set to uppercase and git convert to lowercase

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜