0

I have a git repository, to which I could commit without any issues from other computers in the past. Now, on a new computer, I clone the repository, modify a file, and add it.

Then, I try commit, and apparently I had not set up editor correctly, so instead of TextEdit opening (which I wanted) Vi opens in the terminal editing the file. Vi is closed abnormally, and then I set up in bash the editor correctly, and try again. I try to commit using TextEdit (or other editors after that) to write the commit message, I get the following message in a popup window: 'The document “COMMIT_EDITMSG” could not be opened. You don’t have permission.'

This does not happen when I use git commit -m"..." in the terminal.

I know there are a few threads with relevant topics, which I have seen. For example: About fatal: could not open '.git/COMMIT_EDITMSG': Permission denied

could not open git/commit_editmsg

fatal: could not open '.git/COMMIT_EDITMSG': Permission denied

or

"unable to append to .git/logs/refs/heads/master" when commiting

to name a few.

I tried doing several things mentioned in them:

  • chmod -R u+x .git
  • sudo chown -Rc $UID .git/ (and got the message "chown: illegal option -- c")
  • chmod 664 COMMIT_EDITMSG
  • delete the file COMMIT_EDITMSG
  • git init --shared=0777
  • delete the local repository from hard disk, clone from GitHub, and try again

So far no luck. I can only commit doing git commit -m"..." (and then successfully push to remote), but never using an editor for writing the message.

In case it helps, OS is macOS Sierra.

If anyone has any idea what I could be doing wrong, or what I missed in the relevant topics, I would be grateful.

Community
  • 1
  • 1
eidimon
  • 29
  • 9

2 Answers2

2

okay, after a lot of tries at different occasions, I found something that actually worked in my case:

I went and edited the config file in my local git repository. there, under [core], I added the following:

editor = open -a TextEdit -W

(using TextEdit as the desired editor)

For some reason, when I had the same in my bash profile file, the result was not the same...

eidimon
  • 29
  • 9
0

Yaa! I also face this type of stuff. But is simple to solve. Open your folder you reserved as the repository and open your cmd on those paths and give the commands I suggest belowe.

attrib -h -s -r /s /d *.*

del.git/COMMIT_EDITMSG

so it is working guys.

  • Hello @smit Prajapati, thank you for your first answer. A way to improve it could be to explain why the two commands you give solve the problem, so that people with similar, bu tnot exactly the same, problem could also benefit from your answer. (You probably already know, but if not, you can edit your post with the grey "Edit" link on the bottom left. – Bromind Feb 04 '21 at 10:51