Git and Gitlab Please make sure you have the correct access rights and the repository exists (Solved)


I created a Repository in GitLab.


Go to

Register and Login with Valid credentials.

Go to

Click on New Project.

Create Project in GitLab

Give Proper name and Select Visibility. Click on Create.

Project in Gitlab

You will get command line instructions on Git global setup, Create a new repository, Existing folder, and Existing Git repository.

In my case, I had repository available in File System.

So I tried to follow instructions for Existing folder.

cd existing_folder
git init
git remote add origin
git add .
git commit -m "Initial commit"
git push -u origin master

However, while Pushing the code with git push -u origin master, I faced errors.

$ git push –set-upstream origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.


Go to Git Bash

Generate SSH Keys using following command:  ssh-keygen -t rsa -b 4096 -C “”

It will generate Public and Private Key in a Directory.

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Mitesh/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Mitesh/.ssh/id_rsa.
Your public key has been saved in /c/Users/Mitesh/.ssh/
The key fingerprint is:
The key’s randomart image is:
+—[RSA 4096]—-+
| |
| . F|
| +.|
| ..==|
| S .=.+o|
| . .++=+ |
| . BoE..|
| . &DO+|
| =YXX^|

Go to that directory and open in Editor.

Copy the Key content.

Go to GitLab.

Go to and click on SSH Keys.

Paste your public SSH key, which is usually contained in the file ‘~/.ssh/’ and begins with ‘ssh-rsa’. Don’t use your private SSH key.

Click on Add Key.

SSH Keys in Gitlab

Verify newly added key in Gitlab.

Now use git push –set-upstream origin master

$ git push -u origin master
Counting objects: 304, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (284/284), done.
Writing objects: 100% (304/304), 87.56 KiB | 0 bytes/s, done.
Total 304 (delta 80), reused 0 (delta 0)
remote: Resolving deltas: 100% (80/80), done.
* [new branch] master -> master
Branch master set up to track remote branch master from origin.


Leave a comment

Your email address will not be published. Required fields are marked *