9

I've been using the GitHub for Mac app but on the suggestion of a friend, decided to give Tower a shot since it can also handle Beanstalk accounts as well.

After installing the trial and putting in my GitHub username and password, I'm given this error:

error: could not lock config file /Users/joshferrara/.gitconfig: Permission denied

I was just curious if anyone knows what's causing this or if it has any relevance to me using Tower. Any help is greatly appreciated!


Permissions on the file:

-rw-rw-rw- 1 joshferrara staff 130 Nov 22 17:14 /Users/joshferrara/.gitconfig

Permissions on the parent directory:

drwxr-xr-x 74 501 staff 2516 Apr 26 14:46 /Users/joshferrara
joshferrara
  • 759
  • 2
  • 7
  • 13
  • 2
    Well, what do the ownership and permissions of the config file look like? `ls -l /Users/joshferrara/.gitconfig` – larsks Apr 26 '12 at 20:12
  • @larsks I've tried messing with that, but currently it's `-rw-rw-rw-` – joshferrara Apr 26 '12 at 20:18
  • Also, what are the permissions (*and ownership*) of the parent directory? `ls -ld /Users/joshferrara`? – larsks Apr 26 '12 at 20:24
  • @larsks It's owned by my user, `joshferrara`. Full output: `-rw-rw-rw- 1 joshferrara staff 130 Nov 22 17:14 /Users/joshferrara/.gitconfig` – joshferrara Apr 26 '12 at 20:26
  • 1
    Huh, I'm stumped then. I was sort of hoping to see the actual output of those two commands (ideally, added to your question so that other people will see them, too). – larsks Apr 26 '12 at 20:28
  • @larsks `drwxr-xr-x 74 501 staff 2516 Apr 26 14:46 /Users/joshferrara` – joshferrara Apr 26 '12 at 20:28
  • @larsks I can definitely do that. Sorry, I'm new here! – joshferrara Apr 26 '12 at 20:32
  • Thanks! It helps if your question contains any additional information that people request. I'm stumped, but maybe someone else will be able to help out. Good luck! – larsks Apr 26 '12 at 20:34

4 Answers4

6

I was facing the same issue. I renamed my .gitconfig file to "xyz.gitconfig" And I found that git created a new .gitconfig file. I was not facing the error anymore.

DolphinJava
  • 2,682
  • 1
  • 23
  • 37
4

It turned out to be an odd permission issue between the .gitconfig file that Github for Mac created with root privileges and Tower wasn't able to access.

A simple change of ownership privileges fixed the problem. Ownership can be changed like so:

sudo chown -R username [file|directory]

Explanation:

  • sudo - grant root privileges
  • chown - changes the ownership
  • -R - for recursive changing of files
  • username - username of new owner
  • [file|directory] - file or directory for change to occur (if directory is specified it's going to recursively change all the files inside)
Dawid Zbiński
  • 5,521
  • 8
  • 43
  • 70
joshferrara
  • 759
  • 2
  • 7
  • 13
  • 5
    can you tell what you actually did? like what permissions does the .gitconfig have now? – uday Jan 03 '14 at 03:08
  • 6
    -1 for useless answer. The point of this site is for us to help each other figure things out. Simply announcing that you solved your own problem doesn't help anyone. – emersonthis Apr 30 '14 at 13:27
  • I had same issue and when I ran gitbash as administrator the problem solved – Azadeh Khojandi Jan 09 '15 at 00:35
  • For anyone wondering, i fixed it with `sudo chown myusername -R .git/` from within that local repo directory – Don Rhummy Sep 27 '16 at 00:01
1

Look for .gitconfig.lock file at your home directory, if you find any remove it. Issue got resolved for me.

  • This post isn't an actual attempt at answering the question. Please note [StackOverflow doesn't work like a discussion forum](http://stackoverflow.com/tour), it is a Q&A site where every post is either a question or an answer to a question. Posts can also have [comments](http://stackoverflow.com/help/privileges/comment) - small sentences like this one - that can be used to critique or request clarification from an author. This should be either a comment or a [new question](http://stackoverflow.com/questions/ask) – ρяσѕρєя K Jan 06 '17 at 10:23
0

You mentioned global read/write permissions on the .gitconfig file, and those are enough to edit it. But those aren't enough to create a new file in that directory, which is what the git config tool I am guessing you were using was trying to do.

Now changing the permissions in your home directory might not be an option. It wasn't for me just now googling for this question, for instance, since I'm working on a webserver. So I went into my home account on my own computer, copied my stuff from the gitinfo file there, and pasted it into the .gitinfo file in the locked down account.

To save you a step, most of the time we're using git config, we're doing it to set our name and e-mail on systems that require that to use git. So if that's what you were trying, here's the .gitinfo file's contents. Edit your .gitconfig file with your favorite editor, paste this stuff in, change it to reflect you, and you'll be able to use git without any more complaining :

  [user]
    email = nobody@nowhere.com
    name = Joe Schmoe
Jessica Pennell
  • 578
  • 4
  • 14