Home > front end >  Why in my local repo, "git init" throws a fatal error, but is still creating the .git file
Why in my local repo, "git init" throws a fatal error, but is still creating the .git file

Time:01-30

New to git, trying to follow an online course, but my ubuntu is behaving differently to the teacher's. I've searched for my error on stackoverflow and other websites. I found similar problems, but not the same problem. None of the answers helped me, so I made this new question.

In my local repo, when I enter "git init" I get:

error: chmod on /mnt/c/users/jds/documents/projects/testrepo/.git/config.lock failed: Operation not permitted

fatal: could not set 'core.filemode' to 'false'

However, in the folder (as seen in file explorer) I can see the .git file has been created.

If I then run the "git status" command, I get:

fatal: not a git repository (or any parent up to mount point /mnt)

Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Here is my ubuntu terminal, with the Windows File Explorer in the background (showing the .git file has been created in the repo)

I am on Windows 10, running this in Windows Subsystem for Linux.

----------------- UPDATE ------------------

I deleted the .git file and restarted ubuntu as the root user. When doing the above commands as the root user, it worked:

root@LAPTOP-ILK7ETOO:/mnt/c/users/jds/documents/projects/testrepo# git init

Initialized empty Git repository in /mnt/c/users/jds/documents/projects/testrepo/.git/

root@LAPTOP-ILK7ETOO:/mnt/c/users/jds/documents/projects/testrepo# git status

On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

root@LAPTOP-ILK7ETOO:/mnt/c/users/jds/documents/projects/testrepo#

But why couldn't I do this as the named user? I checked permissions with "ls -l" and the testrepo had full permissions enabled:

drwxrwxrwx 1 root root 512 Jan 29 18:06  testrepo

CodePudding user response:

why couldn't I do this as the named user?

Because your non-root user can't chmod file, as written in error-message. And "How to fix it" is out of scope of SO

PS - existing .git dir is not a sign of functional Git-repository

  •  Tags:  
  • Related