16

I am trying to push an app to Heroku using the CLI. When I enter the command git add . in the terminal, I keep getting this error:

/Users/me/.config/git/ignore': Permission denied
'/Users/me/.config/git/attributes': Permission denied

Can anyone help?

Pang
  • 9,564
  • 146
  • 81
  • 122
denskiz
  • 161
  • 1
  • 2
  • 5
  • Is this same as yours? https://stackoverflow.com/questions/4269922/permission-denied-publickey-when-deploying-heroku-code-fatal-the-remote-end – Sahan Serasinghe Jun 29 '17 at 01:58
  • 2
    @Sahan No. That question is about a remote server denying the push. This is about local file permissions. – Jonathon Reinhart Jun 29 '17 at 01:59
  • 2
    What're the owner, group, and permissions on that attributes file? – jpmc26 Jun 29 '17 at 02:06
  • I am the owner and I have read and write permissions on the file. – denskiz Jun 29 '17 at 02:11
  • I believe this is the same error as https://stackoverflow.com/a/47995027/. basically if you run a command with sudo and it creates the .config directory then root becomes owner. git then checks the .config (now its created and causes the error) – seanv507 Nov 28 '19 at 14:22

11 Answers11

27

Here's how I solved it:

  1. In Terminal cd to the User director with cd ~.

  2. Change the directory permissions with sudo chmod 755 .config

  3. Enter your login password.
MeltingDog
  • 14,310
  • 43
  • 165
  • 295
3

use this command to solve this problem ( commit to git ):

sudo chown -R hamid /Users/hamid

after that enter your Mac login password and allow that's dialogs appear

take attention that hamid is my username and you should enter your username instead of that . You can use the below command to get your username:

id -un
Hamid Reza Ansari
  • 1,107
  • 13
  • 16
1

I had similar error messages outputting from git commands, though the usual set of git commands (pull, push, checkout, etc.) still worked just fine. sudo chmod 755 /home/your-username-here/.config/ followed by entering your login password successfully changed the permission and got rid of the error messages. Reference

1

As suggested by @seanv507 in the comments section, the answer is similar to this answer. The copy/pasta is:

cd ~/
ls -al
<Noticed .config was owned by root, unlike everything else in $HOME>
sudo chown -R $(whoami) .config
pyjavo
  • 1,598
  • 2
  • 23
  • 41
0

While you might be the owner of the files, check the permission of the parent folders .config, .config/git (as in here)

And check if the session in which you push to Heroky has the right HOME anbd XDG_CONFIG_HOME environment variable values.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

This is the command that worked for me:

sudo chown -R USER:(id -gn $USER) /Users/myusername/.config

The only thing that changed here was myusername; the other places where it mentioned USER were left the same.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
0

I had to add the private ssh key to my SSH agent. I was able to do this through command line, then Git Kraken worked.

eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/id_rsa

"id_rsa" or whatever you have named your private key and public key pair that you have added to your github.

reference: https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

rcadby
  • 11
  • 1
  • 4
0
$ git config --global core.fileMode false

use this and then commit changes and then check the log it will work.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
0
/Users/me/.config/git/ignore': Permission denied
/Users/me/.config/git/attributes': Permission denied

Solution: For this go to terminal just run command below :

sudo chmod 755 /Users/your-username/.config

in your case it will be :

sudo chmod 755 /Users/me/.config
Al-Amin Sarker
  • 508
  • 3
  • 16
sapna
  • 1
0

sudo chmod -R 777 /path/to/dir worked for me.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 01 '22 at 02:52
-3

Use sudo before write the command.

sudo git add.
manu
  • 199
  • 3
  • 10