Creating git repo on NTFS in Linux

This problem could affect those of you who dual-boot Windows and some flavour of Linux on the same machine. You have the following partitions you have access to:

  1. Linux partition (likely ext4) for your own home directory
  2. NTFS partition to hold the Windows OS
  3. Shared NTFS partition to hold stored data files that you might want to access from both Linux and Windows OSes

If you work from the Linux OS primarily and want to store your git repository files in a shared NTFS partition (Partition #3 above) like I do, you may encounter the following error message when you attempt initialise the repo with the command git init.


[user@dell myrepo]$ git init .
error: chmod on /path/on/ntfs/filesystem/myrepo/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'

I have found remedies suggested on various sites, such as setting the filemode setting to false in some global configuration file, or setting the NTFS driver to accept permissions by editing the /etc/fstab file.

Unfortunately, neither of the two solutions worked for me. The git program created a .git directory in the local repo and tried to chmod certain files created within that directory. The linux command chmod is not supported by NTFS and an error was returned.  I am running Arch Linux distribution by the way.

As a workaround, I simply made a symbolic link .git from the repo directory in Partition #3 to some directory in Partition #1, where my home directory resides. I created some directory dedicated to this in my home directory.


[user@dell myrepo]$ mkdir -p /home/user/.gitconfigs/myrepo
[user@dell myrepo]$ ln -s /home/user/.gitconfigs/myrepo .git

Proceed as before with “git init .” and voila! That should work. Follow the standard instructions commonly provided to initialise the local repo.

Pulling in an existing repo

Now what if you wanted to pull an existing repo into the NTFS partition? Unfortunately git clone fails too, as we can see in the example below.


[user@dell repos]$ git clone https://github.com/somerepo
Cloning into 'somerepo'...
error: chmod on /path/on/ntfs/filesystem/somerepo/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'

Again, the workaround works on similar ideas. Create the directory for the repo on the NTFS filesystem, and create the symbolic link back to some directory (~/.gitconfigs/somerepo in the example below) in Partition #1.


[user@dell repos]$ mkdir somerepo
[user@dell repos]$ cd somerepo
[user@dell somerepo]$ mkdir -p /home/user/.gitconfigs/somerepo
[user@dell somerepo]$ ln -s /home/user/.gitconfigs/myrepo .git
[user@dell somerepo]$ git init .
[user@dell somerepo]$ git remote add origin https://github.com/username/somerepo
[user@dell somerepo]$ git pull origin master

Leave a comment