Search code examples
gitssh-agentgit-init

How can I create remote repository from local system without creating a repository directly from github portal?


I am a newbie at Git. I am still learning.

Here are the steps that I have taken in order to create the repository so far:

  1. Navigated to the directory that is going to be associated with the repository.
  2. Ran the command: git init
  3. Then I checked the status of all the untracked files using the command: git status
  4. I needed to commit all the files so I added all to the staged files using the command: git add .
  5. I committed the code using the command: git commit -m "Initial Commit"
  6. Then I tried to push the code using the command: git push --set-upstream origin master
  7. Since the remote is not set yet, I faced the error: fatal: No configured push destination.

After the facing the above error, I tried to add the remote using the command:

git remote add origin git@github.com:username/repo-name
git push --set-upstream origin master

After hitting the above commands, I faced the error:

The authenticity of host 'github.com (IP)' can't be established.

So I tried to create an SSH key as suggested in this link. The SSH key was created successfully, but when I tried to add my SSH key to the ssh-agent using the following commands:

eval $(ssh-agent -s)

I encountered the following error:

'eval' is not recognized as an internal or external command

I also tried to execute ssh-agent -s directly, but then I encountered the following error:

unable to start ssh-agent service, error :1058

I googled the issue and found this link. I tried to use the following commands:

> Set-Service ssh-agent -StartupType Manual
> install-sshd.ps1

But both have given me the following errors respectively:

> 'Set-Service' is not recognized as an internal or external command
> 'install-sshd.ps1' is not recognized as an internal or external command

By the way I am using Windows 10.

What should I do next?


Solution

  • Try and create an SSH key, for testing, without passphrase: you won't need an ssh-agent then.

    ssh-keygen -t rsa -m PEM -P"" -C "your@email.com"
    

    Copy the %USERNAME%\.ssh\id_rsa.pub content to GitHub account.

    Test it with ssh -T git@github.com (type 'yes' if it asks you)

    Finally, try your git push -u origin master again.

    Note... you still need to create an empty GitHub repo first on GitHub side.