2

Running git on OVM Ubuntu, when checking for valid credential all is OK:

git config user.name 
roland 

but when I attempt to commit

 git commit –m “add an ‘about’ page

I get the error message:

 fatal: could not open ‘.git/COMMIT_EDITMSG’: Permission denied

when I run git log I see that previous commits have been ascribed to

 Author: root<root@mymodem.box>

Any clues as to what to do to enable authorship of commits, etc.? This issue arises in a completely local environment. Thanks.

RCrim
  • 29
  • 3
  • 1
    Possible duplicate of [fatal: could not open '.git/COMMIT\_EDITMSG': Permission denied](http://stackoverflow.com/questions/19917094/fatal-could-not-open-git-commit-editmsg-permission-denied) – crashmstr Mar 06 '17 at 18:12
  • Also related: [could not open git/commit_editmsg](http://stackoverflow.com/questions/12139239/could-not-open-git-commit-editmsg) – crashmstr Mar 06 '17 at 18:13
  • check your umask and the umask of others that have commited to the repository. Be sure it is set so that it doesn't just restrict new folders from being modified by your account. – g19fanatic Mar 06 '17 at 21:37

2 Answers2

5

Try deleting .git/COMMIT_EDITMSG

And then re-run the commit.

lakeIn231
  • 1,177
  • 3
  • 14
  • 34
3

You made the previous commits as root. Maybe you even initialized the repository as root. This means some of the files that git created are owned by root. Files owned by root can usually not be modified by other users.

The fix is to chown all the files in the repo to your normal user ID. This has to be done as root.

In general, you should only use root credentials for things that need them.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94