fatal: cannot update the ref ‘HEAD’: unable to append to ‘.git/logs/HEAD’: Permission denied

Posted by

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Error :

fatal: cannot update the ref ‘HEAD’: unable to append to ‘.git/logs/HEAD’: Permission denied

Solution:

The error you’re seeing:

fatal: cannot update the ref 'HEAD': unable to append to '.git/logs/HEAD': Permission denied

means that your current user (demon) does not have write permission to the .git/logs/HEAD file or possibly other files inside the .git directory.

โœ… How to Fix It:

๐Ÿ”ง Option 1: Fix permissions recursively

Run the following command to give the current user ownership of the .git directory and all its contents:

sudo chown -R $(whoami):$(whoami) .git

If you’re sure demon is the right user, you can also use:

sudo chown -R demon:demon .git

๐Ÿ”ง Option 2: Check .git/logs/HEAD permissions directly

You can also fix just that file:

sudo chmod u+rw .git/logs/HEAD

Or, again change ownership:

sudo chown demon:demon.git/logs/HEAD

๐Ÿ” Then, try committing again:

git commit -m "adding"

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x