git 无法打开 .git/FETCH_HEAD

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

git cannot open .git/FETCH_HEAD

gitgithubpermissionscentos

提问by Helen

I have CentOs. I make git and made owner's .git folders group "gitdevelopers". In group "gitdevelopers" add User1 and User2. Now i make git-push and git-pull change from user1 and user2. But users in your computers not work with error:

我有 CentO。我制作了 git 并将所有者的 .git 文件夹组设为“gitdevelopers”。在“gitdevelopers”组中添加 User1 和 User2。现在我从 user1 和 user2 进行 git-push 和 git-pull 更改。但是您计算机中的用户无法正常工作:

git.exe pull -v --no-rebase --progress "origin" error: cannot open .git/FETCH_HEAD: Permission denied

git.exe pull -v --no-rebase --progress "origin" 错误:无法打开 .git/FETCH_HEAD:权限被拒绝

Why?

为什么?

p.s.:And i can connect to server by x-shell with login-password user1 and user2.

ps:我可以通过 x-shell 使用登录密码 user1 和 user2 连接到服务器。

few hours later:: I think problem in not right login-password, which git remember.

几个小时后::我认为登录密码不正确的问题,git 记住了。

p.p.s: where git save login-password pairs? I use ssh-protocol.

pps:git 在哪里保存登录密码对?我使用 ssh 协议。

p.p.p.s.:OK. I have server CentOs with git. On server is two users. And I use TortoiseGit for windows. I configure this so : in each connect system asked login and password for connect to server. And now I wanted know : 1. where is saved this login-password 2. i can permanently saved this pair?

pps:好的。我有带有 git 的服务器 CentO。服务器上有两个用户。我在 Windows 上使用 TortoiseGit。我这样配置:在每个连接系统中都要求连接到服务器的登录名和密码。现在我想知道: 1. 这个登录密码在哪里保存 2. 我可以永久保存这对吗?

回答by Pablo Papalardo

This worked with me

这对我有用

sudo chown -R $(whoami) .git/

回答by Joey Dorrani

error: cannot open .git/FETCH_HEAD: Permission denied

Was one of the first errors that ever happened to me.

是发生在我身上的第一个错误之一。

Perhaps you already knew, but this is possibly happening because of not having permissions for changing/viewing that directory.

也许您已经知道,但这可能是因为没有更改/查看该目录的权限。

The idea is to change the permissions, perhaps use:

这个想法是改变权限,也许使用:

chmod

or

或者

chown

I found further answers here Trying to git pull with error: cannot open .git/FETCH_HEAD: Permission denied.

我在这里找到了进一步的答案Trying to git pull with error: cannot open .git/FETCH_HEAD: Permission denied

回答by Rizo

you can check for the permissions on the file,

您可以检查文件的权限,

ls -l /usr/local/Library/Taps/linode/cli/.git/FETCH_HEAD

ls -l /usr/local/Library/Taps/linode/cli/.git/FETCH_HEAD

and

ls -l /usr/local/.git/FETCH_HEAD

ls -l /usr/local/.git/FETCH_HEAD

回答by Suresh Shinde

Generating a new SSH key pair

生成新的 SSH 密钥对

ssh-keygen -o -t rsa -b 4096 -C "[email protected]"

Adding an SSH key to your GitLab account

将 SSH 密钥添加到您的 GitLab 帐户

Copy your public SSH key to the clipboard and paste it into your user account >  SSH Keys 

For Authentication you need to set configuration in ~/.ssh/config as content bellow;

对于身份验证,您需要在 ~/.ssh/config 中将配置设置为以下内容;

Host domain.com

Hostname domain.com

User git

Port 30001

Preferredauthentications publickey

RequestTTY no

IdentityFile ~/.ssh/id_rsa

You can use commands as;In these command mentioned common variables, replace the related values of those.

您可以将命令用作;在这些命令中提到的公共变量,替换那些的相关值。

Create a new repository

创建一个新的存储库

git clone ssh://[email protected]:port-number/user-name/project-name.git

cd project-name

touch README.md

git add README.md

git commit -m "add README"

git push -u origin master

Push an existing folder

推送现有文件夹

cd existing_folder

git init

git remote add origin ssh://[email protected]:port-number/user-name/project-name.git

git add .

git commit -m "Initial commit"

git push -u origin master

Push an existing Git repository

推送现有的 Git 存储库

cd existing_repo

git remote rename origin old-origin

git remote add origin ssh://[email protected]:port-number/user-name/project-name.git

git push -u origin --all

git push -u origin --tags

To clone repository:

克隆存储库:

git clone https://[email protected]:port-number/user-name/project-name.git

git clone https://[email protected]:port-number/user-name/project-name.git

回答by Mohamed Salman

if you are using ubuntu, use sudo key word before.

如果您使用的是 ubuntu,请先使用 sudo 关键字。

sudo git pull

if you are using windows, use administrator mode

如果您使用的是 Windows,请使用管理员模式