Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git commit problem: Unable to append to .git/

I am unable to commit changes in my project when using git.

Here is my terminal:

tomas@tomas-laptop:~/menu_operations$ git commit -m "initial commit"
error: Unable to append to .git/logs/refs/heads/7.x-1.x: Permission denied
fatal: cannot update HEAD ref

menu_operations is the name of my project.

I don't know what permission I have to allow. Can anybody help?

like image 201
tomas.teicher Avatar asked Jul 14 '11 11:07

tomas.teicher


1 Answers

Check the user and permission on .git/logs/refs/heads/, maybe you ran something as root.

Explanation: when you run some git commands as root (sudo?) any new files/directories created will be owned by root, and by default[1] other users won't have write permission on these files/directories.

When you, later, work with that repository, things may appear to work, until the time that you need to write to a file that was in fact created by root, i.e. owned by root.

This should fix it, at least on linux:

 sudo chown -Rc $UID .git/

It will also show you any files that it changed owners for.

[1]in a sane setup, at least

like image 117
sehe Avatar answered Oct 07 '22 00:10

sehe