Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - folder case sensitive issue

Tags:

git

linux

macos

I am trying to bring a already existing codebase in version control system like git.

I am facing a particular issue where codebase contains two folder with same name but different case like 'Form' and 'form'.

Here is the scenario : Suppose, we have three system Linux ( case sensitive file system ) , MAC ( Not case sensitive ) and WINDOWS ( not case sensitive )

Now if someone on LINUX create a folder name FORM having files a.php , b.php , c.php and another folder name form having files a.php , b.php , d.php and pushes it to remote repo

Now when a user on MAC or WINDOWS clone the repo then how will git behave when handling FORM and form coming from remote because MAC and WINDOWS are case insensitive

like image 214
voila Avatar asked Jan 10 '16 04:01

voila


People also ask

Is git case-sensitive for folder names?

The Windows and macOS file systems are case-insensitive (but case-preserving) by default. Most Linux filesystems are case-sensitive. Git was built originally to be the Linux kernel's version control system, so unsurprisingly, it's case-sensitive.

How do I ignore case-sensitive in git?

The cure is to set your ignorecase=false and rename the lowercased files (that git changed that way, not Visual Studio) back to their UsualCase by hand (i.e. 'mv myname MyName').

Are folder paths case-sensitive?

Yes. Windows (local) file systems, including NTFS, as well as FAT and variants, are case insensitive (normally).

Are Git repos case-sensitive?

Yes - the repository names are case sensitive.


3 Answers

You must really fix the file names. It may be useful to use

git config core.ignorecase false

Just in case you want to mix the environment. See more in How do I commit case-sensitive only filename changes in Git?

like image 104
Jayan Avatar answered Oct 20 '22 05:10

Jayan


You should rename your folders so that two sibling folders are never identical (with case-insensitive comparison). This will make your code base more portable, and less error-prone, because developers will not confuse one folder with the other.

like image 31
Adi Levin Avatar answered Oct 20 '22 05:10

Adi Levin


how will git behave when handling FORM and form coming from remote because MAC and WINDOWS are case insensitive

Better, since Git 2.17 (Q2 2018), because Git will keep track of those folders with different case in all instances.

Before, a "git add" files in the same directory, but with spelling the directory path in different cases on case insensitive filesystem, corrupted the name hash data structure and led to unexpected results.

See commit c95525e (08 Feb 2018) by Ben Peart (benpeart).
(Merged by Junio C Hamano -- gitster -- in commit 2ac76d8, 27 Feb 2018)

name-hash: properly fold directory names in adjust_dirname_case()

Correct the pointer arithmetic in adjust_dirname_case() so that it calls find_dir_entry() with the correct string length.

Previously passing in "dir1/foo" would pass a length of 6 instead of the correct 4.
This resulted in find_dir_entry() never finding the entry and so the subsequent memcpy that would fold the name to the version with the correct case never executed.

like image 2
VonC Avatar answered Oct 20 '22 05:10

VonC