6

I'm trying to run:

git checkout master 

and im constantly getting: fatal:

failed to read object 9466835e6cb608c32ec4bf98b2acfa421fd77d3d: Permission denied 

I tried running:

chown -R my-user * 

with no help. any suggestions?

2
  • Inspect (with ls -l) the file .git/objects/9/466835e6cb608c32ec4bf98b2acfa421fd77d3d to see its existing owner and mode. If you ran various Git commands with sudo it may be owned by root. Inspect the .git/objects/ directory as well for all its subdirectories as some of them may be owned by root. Your chown -R is probably going to be a correct solution, except that * will not match .git and therefore it has not been applied to any of the files within .git. Commented Aug 31, 2018 at 15:57
  • sudo chown my_user:my_group -R ./.git/ fixed the problem for me. Commented Sep 24, 2019 at 17:39

1 Answer 1

3

First Try

sudo chmod -R 777 path_to_your_project_folder 

If it does not work try below solution.

Try to do this happens sometimes when dangling blobs are left in git history. You can backup your .git folder and run fsck.

$ git fsck --full 

Refer this answer for more details

Sign up to request clarification or add additional context in comments.

2 Comments

777 is the wrong mode. Most internal .git. files should be 0444 or 0644 or 0664, and most directories should be 0755 or 0775. (However, Git hooks need to be executable, hence 0755 as well.) If your computer is not shared with anyone, 777 will be OK, but if it is shared, you're inviting others to mischief...
Had to run sudo git fsck --full as still got permission denied without running as root

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.