8

I have a git repository linked to a dropbox folder. Recently, I have switched my laptop to another, and now i can not perform the function "git commit -am". I keep getting this error message: "could not open '.git/COMMIT_EDITMSG': Permission denied.

Any ideas?

Thanks, Liron

liron
  • 121
  • 1
  • 1
  • 9

7 Answers7

13

Assuming you're on a Windows machine, the chances are that you modified a hidden file and no longer have write permissions to the hidden file.

To solve this, simply navigate to your .git folder and delete the "COMMIT_EDITMSG" file.

jonplaca
  • 797
  • 4
  • 16
  • 34
5

This is an file permission issue, user you are currently logged on does not have permissions to use the files.

If that's your repo, you may try:

  • switching to other user who owns the repo
  • changing the owner of the repo (sudo chown youruser -R yourrepodir/)
  • changing the permissions for the particular files using chmod (you should avoid using 0777 as it is not secure)
takeshin
  • 49,108
  • 32
  • 120
  • 164
0

try this git init --shared=0777

amitchhajer
  • 12,492
  • 6
  • 40
  • 53
  • Specify that the git repository is to be shared amongst several users. This allows users belonging to the same group to push into that repository. – amitchhajer Aug 27 '12 at 10:00
  • shouldnt it be ennough to change the access right of the folder? Like `chmod 755 ` for information about chmod http://en.wikipedia.org/wiki/Chmod – mbde Aug 29 '12 at 08:28
0

I had this issue when I had a git repo inside a git repo in a working copy.. hope that helps

HaveAGuess
  • 1,231
  • 1
  • 13
  • 23
0

Ensure that the git app you use (whether GUI, cmd or bash) is running as an Administrator. This of course apply if you are using Windows.

Bogdan Stojanovic
  • 678
  • 1
  • 5
  • 15
0

I had same issue, here the steps , how I solved the issue.

1) first checked the file permission( and found, only root having access )

$ls -l .git/COMMIT_EDITMSG

-rw-r--r-- 1 root root 13 Jun 11 07:54 .git/COMMIT_EDITMSG

2) logged in as root and changed file permission

# chown arun:arun .git/COMMIT_EDITMSG ( here arun is my username, refer chown command for more details )

3) Now file permission changed and able to commit without any issues !

$ls -l .git/COMMIT_EDITMSG

-rw-r--r-- 1 arun arun 12 Jun 16 11:47 .git/COMMIT_EDITMSG

Arun
  • 1,651
  • 4
  • 20
  • 31
0

Try deleting .git/COMMIT_EDITMSG

And then re-run the commit.

rm -rf .git/COMMIT_EDITMSG
MADHUR GUPTA
  • 1,014
  • 10
  • 14