Grateful
Grateful

Reputation: 10175

What is going on with this `git clone` statement?

I came across a tutorial that asked for the following statement to be executed.

git clone -b 00 [email protected]:gothinkster/react-redux-realworld-example-app.git

However, it just ends in a fatal error. Then I tried, replacing the email address with my own... And I got the following message.

ssh: connect to host gmail.com port 22: Network is unreachable fatal: Could not read from remote repository.

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

I am trying to discover what the above statement is doing exactly. How can I get around the problem?

Update

Although, I can regularly clone the repository using the full github address with git clone https://..., I would still like to use and understand the original statement above.

Upvotes: 1

Views: 125

Answers (2)

Grateful
Grateful

Reputation: 10175

@EliKor explained the following in his answer.

The -b 00 option for git clone is telling to point the HEAD of your clone of the repository to the branch specified by the following name. In this case the branch name is 00. See documentation on git clone -b here. The [email protected]:gothinkster/react-redux-realworld-example-app.git that follows is the location of the repository that you want to clone. It is in the format [user]@[host]:[directory_location], which is what you'll see for utilities like scp. Github allows you to clone repositories using the SSH protocol, in which you set up an SSH key on your machine and share the public key with github to be used to authenticate you.

So, it is now quite apparent that to use the git clone statement mentioned in the question above, one would have to set up an SSH key and connect to GitHub using that. For details on how to do that, please follow the link provided by @EliKor.

However, it appears that the benefit in doing that is simply the following, as mentioned by the documentation.

Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.

So, for those of you who are happy to connect regularly using your username and password, simply use the following git clone statement instead. No need for the extra headache of setting up an SSH with GitHub.

git clone -b 00 https://github.com/gothinkster/react-redux-realworld-example-app.git

It works like a beauty!

Upvotes: 0

EliKor
EliKor

Reputation: 199

The -b 00 option for git clone is telling to point the HEAD of your clone of the repository to the branch specified by the following name. In this case the branch name is 00. See documentation on git clone -b here. The [email protected]:gothinkster/react-redux-realworld-example-app.git that follows is the location of the repository that you want to clone. It is in the format [user]@[host]:[directory_location], which is what you'll see for utilities like scp. Github allows you to clone repositories using the SSH protocol, in which you set up an SSH key on your machine and share the public key with github to be used to authenticate you. See more details on this here. To get this working I would follow along with the instructions from the previous link and set up your own ssh key with Github.

Upvotes: 5

Related Questions