在本地克隆 Git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4941090/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:01:53  来源:igfitidea点击:

Cloning Git repository locally

gitssh

提问by Chris Mitchell

I have just create a git repository on my iMac under the user git account and am now want to clone it from my main user account on the same computer. I have created my SSH key and added it to the .ssh/authorized_keys file. However when I log back in with my main account I get the following error message:

我刚刚在 iMac 上的用户 git 帐户下创建了一个 git 存储库,现在我想从同一台计算机上的主用户帐户克隆它。我已经创建了我的 SSH 密钥并将其添加到 .ssh/authorized_keys 文件中。但是,当我使用主帐户重新登录时,收到以下错误消息:

Permission denied (publickey) fatal: The remote end hung up unexpectedly

权限被拒绝(公钥)致命:远程端意外挂断

Now to me, and while searching on the web it seems like my public key is incorrect. I have created it twice and still get the same issue.

现在对我来说,在网上搜索时,我的公钥似乎不正确。我已经创建了两次,但仍然遇到同样的问题。

回答by William Pursell

You shouldn't need an ssh key at all. Make all of the files world readable and just clone the full path. In other words, do

您根本不需要 ssh 密钥。使所有文件都可读,只需克隆完整路径即可。换句话说,做

$ git clone /path/to/repo

回答by HBlend

git clone /path/to_repository  /path/to_where_you_want_it_cloned

Make sure that your main user account has permissions to copy to/from your accounts directories.

确保您的主用户帐户有权复制到/从您的帐户目录。