bash Gitconfig:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32122299/
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
Gitconfig: Permission denied
提问by U r s u s
I wanted to edit my .gitconfig
file to change the default editor.
我想编辑我的.gitconfig
文件以更改默认编辑器。
I typed $HOME/.gitconfig
to set the correct directory and got
我输入$HOME/.gitconfig
以设置正确的目录并得到
-bash: /Users/Myself/.gitconfig: Permission denied
.
-bash: /Users/Myself/.gitconfig: Permission denied
.
Why does it happen and what does it mean? How do I get past it?
为什么会发生,这意味着什么?我该如何度过难关?
(OS X Yosemite 10.10.4)
(OS X 优胜美地 10.10.4)
采纳答案by theoden8
You don't have permission to access $HOME/.gitconfig
. Use open "$HOME/.gitconfig"
to open the file in your default text viewer.
您无权访问$HOME/.gitconfig
. 用于open "$HOME/.gitconfig"
在默认文本查看器中打开文件。
回答by Pierre-Olivier Vares
Just use git command :
只需使用 git 命令:
git config --global core.editor your-favorite-editor
--global
instructs git to change your global config (effectively stored in $HOME/.gitconfig), adding the following line in the [core] section :
--global
指示 git 更改您的全局配置(有效存储在 $HOME/.gitconfig 中),在 [core] 部分添加以下行:
editor=your-favorite-editor
You can add it by hand; but for that, as said by others, you mustn't try to execute$HOME/.gitconfig, but you have to openit (with a text editor)
您可以手动添加;但为此,正如其他人所说,你不能尝试执行$HOME/.gitconfig,但你必须打开它(使用文本编辑器)
回答by mgarciaisaia
If you want to editthat file, you should launch an editorand open the file with it.
如果你想编辑那个文件,你应该启动一个编辑器并用它打开文件。
If you type a file name as a command in a UNIX shell, the OS will try to runthat file as a program, but your .gitconfig
doesn't have exec permissions - that's the error you see.
如果您在 UNIX shell 中键入文件名作为命令,操作系统将尝试将该文件作为程序运行,但您.gitconfig
没有 exec 权限 - 这就是您看到的错误。
You can try running $EDITOR $HOME/.gitconfig
, which could get expanded to something like vim ~/.gitconfig
(or whatever editor you have in your $EDITOR
env variable).
您可以尝试 running $EDITOR $HOME/.gitconfig
,它可以扩展为类似的内容vim ~/.gitconfig
(或您在$EDITOR
env 变量中拥有的任何编辑器)。