Case Sensitive Git on a Mac like a Boss

Case Sensitive Git on a Mac like a Boss

The Problem

By default, MacOs uses a filesystem format that is not case sensitive Mac OS Extended (Journaled). That means that the directories a and A are essentially the same. This is a problem when working collaboratively with people using Linux or another case sensitive file system.

Real world Example

Magento uses some wacky theory for storing product images when they are uploaded in case sensitive directories. So the following files would go into the respective directories.

abc.jpg  =>  pub/media/catalog/product/a/b/abc.jpg

aBc.jpg  =>  pub/media/catalog/product/a/B/aBc.jpg

Abc.jpg  =>  pub/media/catalog/product/A/b/Abc.jpg

This may not be an issue if you are developing without using Git or some other type of version control (like a maniac). In a collaborative environment where Git is used, when you try to clone or pull the changes to the catalog/product directory it will combine the directories and the site will not be able to find the correct product images.

The Solution

The best solution is to use the Mac OS Extended (Case-sensitive, Journaled) filesystem. You can create a new partition that is case sensitive without much hassle using Disk Utility on the mac.

Convenience

Move your project directory to the new case sensitive partition. For example if you use the ~/Sites directory for projects, you would issue the following command in the terminal.

$ mv ~/Sites /Volumes/Case\ Sensitive/

Create a symlink to the new case sensitive directory so you dont disrupt your workflow.

$ ln -nfs /Volumes/Case\ Sensitive/Sites/ ~/Sites