Software⏱️ 4 min read📅 2026-06-03

How to Fix: Trying to git pull with error: cannot open .git/FETCH_HEAD: Permission denied

Git permission denied error resolved by changing ownership or using sudo with -i flag.

Quick Answer: Change the ownership of .git directory to your user account, or use sudo git pull with -i flag to specify interactive mode.

The error 'cannot open .git/FETCH_HEAD: Permission denied' occurs when the Git repository is unable to access the FETCH_HEAD file, which is used for fetching changes from a remote repository. This issue typically affects users who have not properly configured their Git environment or have encountered permission-related issues with their system.

This error can be frustrating because it prevents users from updating their local repository with the latest changes from the remote repository. However, by following the steps outlined in this guide, you should be able to resolve the issue and continue using your Git repository without any further problems.

⚠️ Common Causes

  • The primary reason for this error is a permission issue related to the .git directory. When the Git repository is created, it often inherits the permissions from the parent directory. If the parent directory has restrictive permissions, it can prevent the Git repository from accessing its own files, including FETCH_HEAD.
  • Another possible cause of this error is an issue with the SSH keys used for authentication. If the SSH key is not properly configured or is missing, Git may refuse to authenticate and result in a Permission denied error.

🔧 Proven Troubleshooting Steps

Resolving Permission Issues using File Permissions

  1. Step 1: Step 1: Open the Terminal and navigate to the repository directory where you encountered the issue. Type the command `ls -ld .git` to view the file permissions of the .git directory.
  2. Step 2: Step 2: Use the command `chmod u+x .git/FETCH_HEAD` to change the permissions of the FETCH_HEAD file to read and write for all users (u+x). Repeat this step for any other files or directories that are causing permission issues.
  3. Step 3: Step 3: Verify that the changes took effect by attempting to run the Git pull command again. If you still encounter permission errors, proceed with Method 2.

Resolving Permission Issues using SSH Key Configuration

  1. Step 1: Step 1: Open the Terminal and navigate to your home directory (e.g., `cd ~`). Type the command `ssh -T git@github.com` to test your SSH connection. If you encounter a permission error, proceed with Method 3.
  2. Step 2: Step 2: Generate or update your SSH key pair using the command `ssh-keygen -t rsa -b 4096`. Follow the prompts to create a new key pair and add it to your GitHub account.
  3. Step 3: Step 3: Update your Git configuration file (usually located at `~/.gitconfig`) by adding the following lines: `Host github.com User git UserKey ` Replace `` with the actual path to your SSH key file. Save and close the file.

✨ Wrapping Up

By following these steps, you should be able to resolve the 'cannot open .git/FETCH_HEAD: Permission denied' error and continue using your Git repository without any further issues. Remember to always verify your SSH connection and update your Git configuration regularly to ensure a smooth workflow.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions