'Git init: fatal: could not set 'core.filemode' to 'false'
Using Team City to check out from a Git Repo. (Gitlabs if it matters)
Start with Empty build directory. Get this error:
fatal: could not set 'core.filemode' to 'false'
(Running on a Windows machine, if that matters)
The user that Team City is running on was changed to an Admin just in case.
The .Git directory is not a valid Repo when this command exits.
Wiping the entire 'work' directory doesn't help.
It randomly comes and goes...
AND this: git config --global --replace-all core.fileMode false
Does nothing useful - with or without the --replace-all, and run as admin, or another user (if you change 'false' to 'true' you get the same error, if you change it to 'falseCD' it changes the error to that being an invalid value - so clearly, it is changing it.
Anyone got any ideas?
Solution 1:[1]
In my case using "sudo" worked for me. For example:
asif@asif-vm:/mnt/prog/protobuf_tut$ git clone https://github.com/protocolbuffers/protobuf.git
Cloning into 'protobuf'...
error: chmod on /mnt/prog/protobuf_tut/protobuf/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'
After doing a "sudo" I could get it working:
asif@asif-vm:/mnt/prog/protobuf_tut$ sudo git clone https://github.com/protocolbuffers/protobuf.git
Cloning into 'protobuf'...
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 66782 (delta 0), reused 0 (delta 0), pack-reused 66777
Receiving objects: 100% (66782/66782), 55.83 MiB | 2.04 MiB/s, done.
Resolving deltas: 100% (45472/45472), done.
Checking out files: 100% (2221/2221), done.
Solution 2:[2]
I hate to be that guy, but I solved this by restarting Windows.
Solution 3:[3]
For me it was a matter of commenting out two lines in /etc/nsswitch.conf
the lines I commented out were:
group: files # db
db_enum: cache builtin
then closing and reopening cygwin
Solution 4:[4]
I was getting this error when running git init on a windows shared drive mount into linux via samba. I used sudo for init, then chown back to original user, and all was good from there on:
sudo git init # no error
sudo chown user:user .git -R # drop sudo requirement
git add file1 # works normally
git commit -am bla # works normally
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | linuxstack |
| Solution 2 | Blairg23 |
| Solution 3 | ShÅgun8 |
| Solution 4 | Shadi |
