Home > OS >  gh-pages --permission denied
gh-pages --permission denied

Time:01-11

I tried updating my react app on github pages, however I can't run the command "npm run deploy". I cloned my repository, made some changes, pushed them to my main branch. All fine. Then when trying to use "run deploy" with GH pages it gives me a "[email protected]: Permission denied (publickey). fatal: Could not read from remote repository.". However, my .ssh key works fine (I was able to push changes to my main branch without any issue). What am I missing here to make it work?

I tried to authenticate to github with my .ssh key and I have no issues. I have no issues pushing changes to my main branch as well.

CodePudding user response:

Some possible causes of this issue:

  • The repository where you are trying to deploy is not a public repository, it is a private repository and you don't have the necessary permissions to push the changes to the gh-pages branch.
  • The gh-pages branch doesn't exist, If the repository doesn't have any GitHub Pages branch, GitHub will not create one until a GitHub Pages build is pushed to it.
  • There is a problem with the gh-pages branch, such as it being deleted or having uncommitted changes. This can cause a problem with pushing to the branch.
  • Your Git configuration is not set up properly. Make sure that your Git global configuration settings, such as email and username, are set correctly.
  • There might be a problem with SSH key. The SSH key that is associated with your GitHub account might have been removed or changed, which would make it impossible for you to push to the repository.
  • There might be a problem with your internet connection or a firewall blocking your connection.
  • You might have enabled 2FA for your GitHub account, in which case you need to generate a personal access token in order to push to your repository.

You could try the following steps to troubleshoot this issue:

  • Try cloning the repository again, and make sure that you are able to access it.
  • Make sure that you are able to push to other branches on the repository
  • Check if the gh-pages branch exists
  • Make sure that your Git configuration settings are set up properly.
  • Check if your SSH key is still associated with your GitHub account.
  • Check your internet connection
  • Check your firewall settings

CodePudding user response:

After fiddling around I found a solution to my problem.

  1. Delete my local repository
  2. Clone it using GitHub Desktop
  3. Then I was able to run "npm run deploy" without any issues

I'm not sure why it works. I'm assuming there was some issues when cloning from the CLI but I'm not sure about what they are exactly.

  • Related