git 无法使用我的 GitHub 帐户设置 Tower - 错误:无法锁定配置文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10340581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trouble setting up Tower with my GitHub Account - error: could not lock config file
提问by joshferrara
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.
我一直在使用 GitHub for Mac 应用程序,但在朋友的建议下,决定试一试 Tower,因为它也可以处理 Beanstalk 帐户。
After installing the trial and putting in my GitHub username and password, I'm given this error:
安装试用版并输入我的 GitHub 用户名和密码后,出现以下错误:
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!
我只是好奇是否有人知道是什么导致了这种情况,或者它是否与我使用 Tower 有任何关系。任何帮助是极大的赞赏!
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
采纳答案by joshferrara
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.
事实证明.gitconfig
,Github for Mac 使用 root 权限创建的文件与 Tower 无法访问的文件之间存在奇怪的权限问题。
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 privilegeschown
- changes the ownership-R
- for recursive changing of filesusername
- 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)
sudo
- 授予root权限chown
- 改变所有权-R
- 用于递归更改文件username
- 新主人的用户名[file|directory]
- 要发生更改的文件或目录(如果指定了目录,它将递归更改其中的所有文件)
回答by DolphinJava
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.
我面临着同样的问题。我将我的 .gitconfig 文件重命名为“xyz.gitconfig”并且我发现 git 创建了一个新的 .gitconfig 文件。我不再面临错误了。
回答by Jessica Pennell
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.
你提到了 .gitconfig 文件的全局读/写权限,这些足以编辑它。但是这些还不足以在该目录中创建一个新文件,这就是我猜你正在使用的 git config 工具试图做的。
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.
现在更改主目录中的权限可能不是一种选择。例如,因为我在网络服务器上工作,所以我现在不适合在谷歌上搜索这个问题。所以我在自己的电脑上进入我的家庭帐户,从那里的 gitinfo 文件中复制我的东西,并将其粘贴到锁定帐户中的 .gitinfo 文件中。
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 :
为了节省您的步骤,大多数时候我们使用 git config,我们这样做是为了在需要使用 git 的系统上设置我们的姓名和电子邮件。所以如果这就是你想要的,这里是 .gitinfo 文件的内容。用你最喜欢的编辑器编辑你的 .gitconfig 文件,粘贴这些东西,改变它以反映你,你就可以使用 git 而不用再抱怨了:
[user]
email = [email protected]
name = Joe Schmoe
回答by user7383416
Look for .gitconfig.lock file at your home directory, if you find any remove it. Issue got resolved for me.
在您的主目录中查找 .gitconfig.lock 文件,如果您找到任何将其删除。问题已为我解决。