Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git error: "Please make sure you have the correct access rights and the repository exists"

People also ask

How do you fix Please make sure you have the correct access rights and the repository exists?

The “Please make sure you have the correct access rights” error occurs if you do not have the right permissions to access a Git repository. To solve this error, make sure you are referring to the correct remote URL and that you have set up SSH authentication correctly.

Could not read from remote repository make sure you have the correct access rights?

The Git “fatal: Could not read from remote repository” error occurs when there is an issue authenticating with a Git repository. This is common if you have incorrectly set up SSH authentication. To solve this error, make sure your SSH key is in your keychain and you connecting to a repository using the correct URL.

How do I check access rights in git?

how can i check write access to a git repository, if i do have a clone of it? A very easy way to check is whether you see an edit 'pencil' icon in the top right of the README.MD on the main Code page of the repo (scroll down to it if there's a long list of top level files/folders).

How do I give permission to GitHub repository?

Under your repository name, click Settings. In the "Access" section of the sidebar, click Collaborators & teams. Click Invite a collaborator. In the search field, start typing the name of person you want to invite, then click a name in the list of matches.


Your git URL might have changed. Change the URL in the local directory by using the following command

for https protocol

git remote set-url origin https://github.com/username/repository.git

for ssh protocol

git remote set-url origin [email protected]:username/repository.git

there might be multiple causes for the issue

  1. If the issue is with your ssh identity, go through @onkar-m18 answer here
  2. If ssh key is not added to hosting server, go through @lovekush-vishwakarma answer here

That problem might be having with your ssh-agent, your ssh key hasn't been added with ssh-agent.You have to apply following steps using your terminal:-

  1. $ eval "$(ssh-agent -s)"

    Agent pid 5867

  2. $ ssh-add

    Enter passphrase for /home/you/.ssh/id_rsa: [] Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)

then it will work..cheers J.


Try to use HTTPS instead SSH while taking clone from GIT, use this Url for take clone , you can use Gitbase, Android Studio or any other tool for clone the branch. enter image description here


For me it was because of no SSH key on the machine. Check the SSH key locally:

$ cat ~/.ssh/id_rsa.pub

This is your SSH key. Add it to your SSH keys in the repository.
In gitlab go to

profile settings -> SSH Keys

and add the key


Github now uses a url scheme

git remote set-url origin https://github.com/username/repository.git


If it was working before and suddenly stopped working:

This issue can be caused because sometimes ssh-agent is not persistent across reboots. You should check if ssh-agent has your key added:

ssh-add -l -E md5

if you get the output like:

The agent has no identities.

it means ssh-agent has lost your key. In that case, you simply need to add the identity key again. Something like:

ssh-add ~/.ssh/git_rsa

The error should disappear now!


If you're on a shared machine, using your own password or passwordless private key might be overkill. The safer option is an access token:

  1. Go to Settings, Developer Settings, Personal access tokens
  2. Generate new token.
  3. Note what the token is for.
  4. Grant repo access.
  5. Clone the repo:
$ git clone https://<token>@github.com/<user>/<repo>.git

If you've already cloned the repo, you could just modify your remote setting:

$ git remote set-url origin https://<token>@github.com/<user>/<repo>.git
$ git pull
Already up to date.