Ask coding questions

← Back to all posts
git cant add file due to permissions! [REPOST]
h
Squirrel777 (138)

So basically I have almost everything resolved! That problem from yesterday? Solved! Which is good, but... what's that? Another permissions error! Oh boy. So basically I did git add ., but that didn't seem to work. I got this instead:

error: open("index.html"): Permission denied
error: unable to index file 'index.html'    
fatal: adding files failed

Anyone know how to fix this?

Things I tried

So I have tried a couple of things... and none of them worked.

  1. git add --ignore-errors . source

  2. chmod 777 myFolder

Answered by Coder100 (17034) [earned 5 cycles]
View Answer
Comments
hotnewtop
Squirrel777 (138)

That didn't seem to work, I already tried it, same for the other answer @Coder100

Coder100 (17034)

ok
maybe you made the files on window and you are using git on wsl @Squirrel777

Squirrel777 (138)

yeah that's exactly what I did @Coder100

Coder100 (17034)

yeah no
oses protect their files from other oses lol
its called security

can't do that @Squirrel777

SorenRood (2)

Ohhhhh, I see his problem now.

Coder100 (17034)

ye
pretty dumb/smort right @SorenRood

Coder100 (17034)

but make sure the file isn't being 'used' (like an editor or smth)

so close any open editors.

SorenRood (2)

You actually have to interact with git using the tab on the left side of the editor. I have not been able to get git commands in terminal to work either.

Coder100 (17034)

r u sure this is replit env @SorenRood

Squirrel777 (138)

I am using vs code, and you use the shell to use git commands not the terminal @SorenRood

SorenRood (2)

Oh I see. Have you added your ssh private key to github? @Squirrel777

SorenRood (2)

@Squirrel777 You may have to cd /home/users/<your-name>/.ssh and then do ssh-keygen -t ed25519 to generate a new key. From there you want to open the .pub key by doing vim <key_name>.pub and then copying the public key into your github account.

SorenRood (2)

@Squirrel777 the path is different if you are on windows. It would be:

Squirrel777 (138)

I already have an ssh key @SorenRood

SorenRood (2)

@Squirrel777 is the public key in your github account?

SorenRood (2)

"permission denied" is usually a auth issue. @Squirrel777

SorenRood (2)

It might be an easy fix if you remove the .git file and try re-adding it to a new git repo. @Squirrel777

SorenRood (2)

Since it is the git add . that is erroring, not the git push.

SorenRood (2)

I can help debug over discord if you want to DM me @ soren#1111

SorenRood (2)

You can also just reclone as https instead of using ssh for now if you'd like @Squirrel777 :