I created a Repository in GitLab.
Go to https://gitlab.com
Register and Login with Valid credentials.
Go to https://gitlab.com/dashboard/projects
Click on New Project.
Give Proper name and Select Visibility. Click on Create.
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 email@example.com:mitesh.soni83/petclinic-blueocean.git 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 “firstname.lastname@example.org”
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/id_rsa.pub.
The key fingerprint is:
The key’s randomart image is:
| . F|
| S .=.+o|
| . .++=+ |
| . BoE..|
| . &DO+|
Go to that directory and open id_rsa.pub in Editor.
Copy the Key content.
Go to GitLab.
Go to https://gitlab.com/profile and click on SSH Keys.
Paste your public SSH key, which is usually contained in the file ‘~/.ssh/id_rsa.pub’ and begins with ‘ssh-rsa’. Don’t use your private SSH key.
Click on Add Key.
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.