xxxxx@LAPTOP-xxxxxxxx /somepath/xxxxxxxxxx$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: .devcontainer/Dockerfile
modified: xxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxx.py
renamed: testing/Full_Attempt_1_without_Preqs_no_oop.py -> full_scripts/Full_Attempt_1_without_Preqs_no_oop.py
deleted: tester_1.py
deleted: testing/Full_Attempt_2_with_Preqs_no_oop.py
new file: unit_tests/xxxxxxxxxxxxxx.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
full_scripts/Full_Attempt_2_with_Preqs_no_oop.py
full_scripts/tester_1.py
test_preq_loader.py
Please nevermind the names of things, but this is pretty much what you see after running git status. When I try to add the missing files with git add ., this is what I get:
error: insufficient permission for adding an object to repository database .git/objects
error: full_scripts/Full_Attempt_2_with_Preqs_no_oop.py: failed to insert into database
error: unable to index file 'full_scripts/Full_Attempt_2_with_Preqs_no_oop.py'
fatal: adding files failed
Which error should I prioritize? Are these errors related? In other examples online there is some explanation of the "unable to index file" error, but I have no insight why I can't index the file.
Also, git commit and git push don't work, but I figured git add is the first one to address.
I'm still learning how git works, but is there something I can change in the objects directory? Inside of the commit/tree/blob DAG?
I'm getting tempted to just copypaste my project into a new git project, but would prefer to keep the project history, and also learn about git, what I can do to fix this, and what went wrong in the first place.
Thanks for any and all feedback/advice.
Response to comments for more information:
- The permissions for .git: drwxrwxrwx
- All subdirectories are either: drwxr-xr-x or drwxrwxrwx
- I'm using WSL2 on windows 10
After reading @torek's answer I wanted to check ownership of objects in the .git/objects folder. When I run ls -l in the .git/objects directory, some of the "xx" directories are owned by me, with permissions 777, and some of the "xx" directories are owned by root, with permissions 755.
When I look into the directories owned by me, some or all of the hashed files will be owned by me with 777 permissions, and maybe some owned by root, with 444 permissions. When I look into the directories owned by root, all of the hashed files are owned by root with 444 permissions.
Final update (maybe): I think I need to change ownership from root to myself for all directories and folders. I also need to change permissions of all xx directories from 755 to 777, and blob/tree/commit hashfiles from 444 to 777. Running (from .git/objects)
sudo chmod -R 777 .
doesn't work to change anything. Also, running (from .git/objects)
sudo chown -R isaac:isaac .
doesn't change anything either. I suppose this is a different issue, so I closed the question. But that's where I'm currently stuck.