Help me please, I am trying to run this in my terminal:
请帮帮我,我正在我的终端上运行这个:
asgard@asgard-A7N8X2-0:~/CollegePortal$ git pull
error: cannot open .git/FETCH_HEAD: Permission denied
Then I try this one
然后我试试这个。
asgard@asgard-A7N8X2-0:~/CollegePortal$ sudo git pull
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Help me, I don't understand this problem.
我不明白这个问题。
16 个解决方案
#1
132
It seems like the first one isn't working because your user doesn't have the permissions for changing that directory, and the second because your root user doesn't have the right SSH keys for accessing that git repository.
第一个似乎不起作用,因为您的用户没有修改该目录的权限,第二个似乎是因为您的根用户没有正确的SSH密钥来访问git存储库。
Depending on what you're trying to do, it might be better to clone the repository to a different directory, or maybe chown
the current directory to have full access for your user
根据您正在尝试的操作,最好将存储库克隆到另一个目录,或者可能共享当前目录,以便为用户提供完整的访问权限
#2
111
Check if you have enough permissions on the .git/
directory. You should have write permissions. You can set them with the following command.
检查.git/目录是否有足够的权限。您应该具有写权限。您可以使用以下命令设置它们。
Go to your project folder:
进入你的项目文件夹:
chown -R youruser:yourgroup .git/
#3
25
This is a UNIX permission problem. Do not use sudo for cloning the repository. You don't have the same ssh keys as root and you shouldn't work as root anyway. Try ls -la to find the permissions on the files and use chmod (or sudo chown) to fix them. Hope that helps.
这是一个UNIX权限问题。不要使用sudo来克隆存储库。您没有与root相同的ssh密钥,也不应该以root身份工作。尝试使用ls -la查找文件的权限,并使用chmod(或sudo chown)修复它们。希望有帮助。
#4
25
If you want to give the permission to the group,
如果你想给这个团体许可,
sudo chmod g+w .git -R
worked best for me.
对我效果最好。
#5
13
The answer to this issue make sure .git/FETCH_HEAD has write privileges and you will be all set.
这个问题的答案是,确保.git/FETCH_HEAD具有写权限,您将全部设置好。
I had this issue on Windows and it was resolved by giving write permissions.
我在Windows上遇到了这个问题,通过授予写权限解决了这个问题。
In unix one can run chmod a+rw .git/FETCH_HEAD
from the project repository after which it should work.
在unix中,可以从项目存储库中运行chmod a+rw .git/FETCH_HEAD,之后它应该可以工作。
#6
12
In my case work fine after it:
在我的情况下,在它之后工作得很好:
rm -f .git/FETCH_HEAD
#7
10
In my case, I only had read access to the .git/FETCH_HEAD file. I had to do "sudo chmod g+w .git/FETCH_HEAD" in order to be able to do a pull request.
在我的例子中,我只有对.git/FETCH_HEAD文件的读访问权限。我必须做“sudo chmod g+w .git/FETCH_HEAD”,以便能够执行拉取请求。
#8
6
I was having the first issue (FETCH_HEAD permission denied) on Windows.
我在Windows上遇到了第一个问题(FETCH_HEAD权限被拒绝)。
I fixed it by running Git Bash as an administrator (right click, run as administrator).
我通过以管理员的身份运行Git Bash(右击,以管理员的身份运行)来修复它。
#9
5
If you haven't added yourself to the group that owns .git/
, then you should.
如果您还没有将自己添加到拥有.git/的组中,那么您应该这样做。
sudo usermod -a -G $(stat -c '%G' .git) $USER
sudo chmod g+u .git -R
sudo chmod g+u .gitignore
su - $USER
What this does:
这样做:
- finds out which group owns
.git/
and adds your user to that group. - 查明哪个组拥有.git/并将用户添加到该组。
- makes sure group members have the same permissions as the owner for
.git/
. - 确保组成员具有与.git/的所有者相同的权限。
- repeats this for
.gitignore
, which you'll probably need - 对。gitignore重复这个,您可能需要它
- logs you out and back in to refresh your group membership file permissions
- 登出并返回以刷新组成员资格文件权限
If you just recently did something like this (added yourself to the group that owns .git/
), then you need to log out and back in before you'll be able to write to .git/FETCH_HEAD
during your git pull
.
如果您最近做了这样的事情(将自己添加到拥有.git/的组中),那么在您能够在git提取期间写入.git/FETCH_HEAD之前,您需要退出并返回。
#10
4
Running Windows 7, when I had this issue it was because I had hidden the .git folder. The permissions were fine, it was just hidden. Showing the folder resolved it.
运行Windows 7时,我遇到这个问题是因为我隐藏了。git文件夹。权限很好,只是被隐藏了。显示文件夹解决了它。
#11
2
Look at the owner and group of .git
directory with (first go to parent directory of .git) ll .git
, look at the group and owner of the directory, add your user to group of of the owner with sudo usermod -a -G yourusername groupsofonwner
, then logout => login and everything getting work.
看看.目录的所有者和组(.第一次去父目录)将.,看目录的组和所有者,将用户添加到组的所有者sudo usermod - a - g yourusername groupsofonwner,然后注销= >登录和一切工作。
So in summeries
因此,在取得
-
go to parent directory of git
转到git的父目录
$cd your path
-
find group owner of the
.git
direcotry查找.git direcotry的组所有者
$ll .git
-
add your user to that group
将您的用户添加到该组。
$usermod -a -G yourusername ownergroupofgit
-
Logout and login to system to this change take effect.
登出和登录系统到此更改生效。
-
Enjoy it ;)
享受它,)
#12
2
Got that issue when .git folder is hidden and all files in it is hidden too. Make only .git folder hidden without recursive files update and it will work.
当.git文件夹被隐藏并且所有文件也被隐藏时,就会出现这个问题。在没有递归文件更新的情况下,只创建.git文件夹,它将工作。
#13
1
This worked for me:
- Right click .git folder
- 右键单击.文件夹
- click get info
- 点击获取信息
- set permission to your user
- 设置用户权限
- click the Cog icon and click apply to enclosed items
- 单击Cog图标,并单击应用附件
No more permission denied errors in git. ????
在git中没有任何权限被拒绝。????
#14
1
Try like this way,
尝试这样的方式,
Step 1: First check who you are? it will return current user name e.g ubuntu
第一步:首先看看你是谁?它将返回当前用户名e。g ubuntu
$ whoami
Step 2: Then set permission to your current user, in that case, ubuntu by
步骤2:然后设置当前用户的权限,在这种情况下,ubuntu by
sudo chown -R ubuntu .git/
#15
0
I got this because I had more than 1 user account on my box. I was logged in as user A and was in a directory for user B. User A didn't have permission to user B's stuff. Once I realized I wasn't where I thought I was in the file system, this error made sense.
我得到这个是因为我有一个以上的用户帐户在我的盒子上。我以用户A的身份登录,在用户B的目录中,用户A没有权限给用户B的东西。当我意识到我不是我认为我在文件系统的地方,这个错误是有意义的。
#16
0
I had this message when using git extensions for windows. My fix was to simply close git extensions then open again as administrator
我在windows中使用git扩展时收到了这条消息。我的解决方案是简单地关闭git扩展,然后作为管理员重新打开。
#1
132
It seems like the first one isn't working because your user doesn't have the permissions for changing that directory, and the second because your root user doesn't have the right SSH keys for accessing that git repository.
第一个似乎不起作用,因为您的用户没有修改该目录的权限,第二个似乎是因为您的根用户没有正确的SSH密钥来访问git存储库。
Depending on what you're trying to do, it might be better to clone the repository to a different directory, or maybe chown
the current directory to have full access for your user
根据您正在尝试的操作,最好将存储库克隆到另一个目录,或者可能共享当前目录,以便为用户提供完整的访问权限
#2
111
Check if you have enough permissions on the .git/
directory. You should have write permissions. You can set them with the following command.
检查.git/目录是否有足够的权限。您应该具有写权限。您可以使用以下命令设置它们。
Go to your project folder:
进入你的项目文件夹:
chown -R youruser:yourgroup .git/
#3
25
This is a UNIX permission problem. Do not use sudo for cloning the repository. You don't have the same ssh keys as root and you shouldn't work as root anyway. Try ls -la to find the permissions on the files and use chmod (or sudo chown) to fix them. Hope that helps.
这是一个UNIX权限问题。不要使用sudo来克隆存储库。您没有与root相同的ssh密钥,也不应该以root身份工作。尝试使用ls -la查找文件的权限,并使用chmod(或sudo chown)修复它们。希望有帮助。
#4
25
If you want to give the permission to the group,
如果你想给这个团体许可,
sudo chmod g+w .git -R
worked best for me.
对我效果最好。
#5
13
The answer to this issue make sure .git/FETCH_HEAD has write privileges and you will be all set.
这个问题的答案是,确保.git/FETCH_HEAD具有写权限,您将全部设置好。
I had this issue on Windows and it was resolved by giving write permissions.
我在Windows上遇到了这个问题,通过授予写权限解决了这个问题。
In unix one can run chmod a+rw .git/FETCH_HEAD
from the project repository after which it should work.
在unix中,可以从项目存储库中运行chmod a+rw .git/FETCH_HEAD,之后它应该可以工作。
#6
12
In my case work fine after it:
在我的情况下,在它之后工作得很好:
rm -f .git/FETCH_HEAD
#7
10
In my case, I only had read access to the .git/FETCH_HEAD file. I had to do "sudo chmod g+w .git/FETCH_HEAD" in order to be able to do a pull request.
在我的例子中,我只有对.git/FETCH_HEAD文件的读访问权限。我必须做“sudo chmod g+w .git/FETCH_HEAD”,以便能够执行拉取请求。
#8
6
I was having the first issue (FETCH_HEAD permission denied) on Windows.
我在Windows上遇到了第一个问题(FETCH_HEAD权限被拒绝)。
I fixed it by running Git Bash as an administrator (right click, run as administrator).
我通过以管理员的身份运行Git Bash(右击,以管理员的身份运行)来修复它。
#9
5
If you haven't added yourself to the group that owns .git/
, then you should.
如果您还没有将自己添加到拥有.git/的组中,那么您应该这样做。
sudo usermod -a -G $(stat -c '%G' .git) $USER
sudo chmod g+u .git -R
sudo chmod g+u .gitignore
su - $USER
What this does:
这样做:
- finds out which group owns
.git/
and adds your user to that group. - 查明哪个组拥有.git/并将用户添加到该组。
- makes sure group members have the same permissions as the owner for
.git/
. - 确保组成员具有与.git/的所有者相同的权限。
- repeats this for
.gitignore
, which you'll probably need - 对。gitignore重复这个,您可能需要它
- logs you out and back in to refresh your group membership file permissions
- 登出并返回以刷新组成员资格文件权限
If you just recently did something like this (added yourself to the group that owns .git/
), then you need to log out and back in before you'll be able to write to .git/FETCH_HEAD
during your git pull
.
如果您最近做了这样的事情(将自己添加到拥有.git/的组中),那么在您能够在git提取期间写入.git/FETCH_HEAD之前,您需要退出并返回。
#10
4
Running Windows 7, when I had this issue it was because I had hidden the .git folder. The permissions were fine, it was just hidden. Showing the folder resolved it.
运行Windows 7时,我遇到这个问题是因为我隐藏了。git文件夹。权限很好,只是被隐藏了。显示文件夹解决了它。
#11
2
Look at the owner and group of .git
directory with (first go to parent directory of .git) ll .git
, look at the group and owner of the directory, add your user to group of of the owner with sudo usermod -a -G yourusername groupsofonwner
, then logout => login and everything getting work.
看看.目录的所有者和组(.第一次去父目录)将.,看目录的组和所有者,将用户添加到组的所有者sudo usermod - a - g yourusername groupsofonwner,然后注销= >登录和一切工作。
So in summeries
因此,在取得
-
go to parent directory of git
转到git的父目录
$cd your path
-
find group owner of the
.git
direcotry查找.git direcotry的组所有者
$ll .git
-
add your user to that group
将您的用户添加到该组。
$usermod -a -G yourusername ownergroupofgit
-
Logout and login to system to this change take effect.
登出和登录系统到此更改生效。
-
Enjoy it ;)
享受它,)
#12
2
Got that issue when .git folder is hidden and all files in it is hidden too. Make only .git folder hidden without recursive files update and it will work.
当.git文件夹被隐藏并且所有文件也被隐藏时,就会出现这个问题。在没有递归文件更新的情况下,只创建.git文件夹,它将工作。
#13
1
This worked for me:
- Right click .git folder
- 右键单击.文件夹
- click get info
- 点击获取信息
- set permission to your user
- 设置用户权限
- click the Cog icon and click apply to enclosed items
- 单击Cog图标,并单击应用附件
No more permission denied errors in git. ????
在git中没有任何权限被拒绝。????
#14
1
Try like this way,
尝试这样的方式,
Step 1: First check who you are? it will return current user name e.g ubuntu
第一步:首先看看你是谁?它将返回当前用户名e。g ubuntu
$ whoami
Step 2: Then set permission to your current user, in that case, ubuntu by
步骤2:然后设置当前用户的权限,在这种情况下,ubuntu by
sudo chown -R ubuntu .git/
#15
0
I got this because I had more than 1 user account on my box. I was logged in as user A and was in a directory for user B. User A didn't have permission to user B's stuff. Once I realized I wasn't where I thought I was in the file system, this error made sense.
我得到这个是因为我有一个以上的用户帐户在我的盒子上。我以用户A的身份登录,在用户B的目录中,用户A没有权限给用户B的东西。当我意识到我不是我认为我在文件系统的地方,这个错误是有意义的。
#16
0
I had this message when using git extensions for windows. My fix was to simply close git extensions then open again as administrator
我在windows中使用git扩展时收到了这条消息。我的解决方案是简单地关闭git扩展,然后作为管理员重新打开。