I needed to take a quick look at a GitHub repository.
I launched a command shell and issued “git clone” against the repository.
Here is the syntax and sample for the git clone command.
git clone firstname.lastname@example.org:[organization]/[repository].git
git clone email@example.com:labOrg/sample.git
Unfortunately, we encountered an error.
The error is:-
firstname.lastname@example.org: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
- Review Command
- What does the command do?
- What application protocol are we using?
What does the command do?
Please review the command.
In our case git clone.
Git Clone copies a remote repository unto our local machine.
Network Application Protocol?
To communicate with a git server we can utilize HTTP or SSH.
- SSH / HTTP / GitHub CLI
SSH / HTTPS / GitHub CLI
Retrieve Git Clone Command
Let us access GitHub and get a copy of the git clone command for our targeted repository.
To get the git clone command, please do the following:-
- Launch a web browser
- GitHub Repository
- Access GitHub web site
- Access your Account by passing along your credentials ( username & password )
- Access your targeted repository
- Within the Targeted Repository
- Access the Code Tab
- Click the Code button
- The various options for getting the Repository Code is displayed
- Here are the options:-
- Clone Command
- Clone HTTP
- Clone SSH
- Clone GitHub CLI
- Open with GitHub Desktop
- Download Zip
- Clone Command
If we click on each GitHub Clone Option, we will be offered the git clone command that we should issue to download the targeted repository.
- Git Hub CLI
- gh repo clone labOrg/sample1
The machine we are using has not been configured to communicate with our GitHub Server using SSH.
To use SSH we will need to create SSH keys on the client workstation and upload those keys on our GitHub Server.
We will thus draw back and use HTTP.
Attempt Git Clone – HTTPS Protocol
Here is the syntax and sample for the “git clone” command.
git clone https://github.com/[organization]/[repository].git
git clone https://github.com/labOrg/sample1.git
>git clone https://github.com/DanielAdeniji/sample1.git Cloning into 'sample1'... info: please complete authentication in your browser... remote: Enumerating objects: 55, done. remote: Counting objects: 100% (55/55), done. remote: Compressing objects: 100% (32/32), done. remote: Total 55 (delta 12), reused 49 (delta 6), pack-reused 0 Receiving objects: 100% (55/55), 10.16 KiB | 1.27 MiB/s, done. Resolving deltas: 100% (12/12), done.
Needlessly, took a lot of time and ink to explain an error message.
The error read:-
email@example.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I really wish the error message was a bit more concise.
I like developers who take the time to give more verbose error messages.
I already know that the machine I am on is a virgin and it is not setup for git.
But pity that your man, who is a bit green, yet wants to start using the command shell more.