DEV Community

Cover image for How to connect Git to GitHub
Ifeanyi Chima
Ifeanyi Chima

Posted on • Edited on

How to connect Git to GitHub

I bought a new laptop and I need to configure it properly. In this series, I will guide you, so that you can use if for programming.

In this article, I will guide you on how to install Git bash (adding a user account) and how to connect to GitHub so that you can upload (push) to your cloud GitHub Repo

1. Installing Git Bash:
Go to the official Git website: https://git-scm.com/downloads

2. Setting up a user account in Git:
After installation, open Git Bash and set up your user account with the following commands:

git config --global user.name "Barack Obama"
git config --global user.email "[email protected]"
Enter fullscreen mode Exit fullscreen mode

3. Connecting to GitHub:

Generate an SSH key (if you don't already have one):

ssh-keygen -t ed25519 -C "[email protected]"
Enter fullscreen mode Exit fullscreen mode

Press Enter to accept the default file location. You can choose to set a password or leave it empty. Now, you can start the SSH agent:

eval "$(ssh-agent -s)"
Enter fullscreen mode Exit fullscreen mode

Add your SSH key to the agent:

ssh-add ~/.ssh/id_ed25519
Enter fullscreen mode Exit fullscreen mode

run the following command and then copy the output, this is your public SSH key

cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

Add the SSH key to your GitHub account:

  • Go to GitHub.com and sign in
  • Click on your profile picture in the top right and select "Settings"
  • In the left sidebar, click on "SSH and GPG keys"
  • Click "New SSH key"
  • Give your key a title (e.g., "My New Laptop")
  • Paste your public key into the "Key" field
  • Click "Add SSH key"

Hopefully, after following the steps stated above, you have successfully linked your computer to GitHub. To test this out, run a git clone command to clone a GitHub repository.

Clone your repository
If you do not have any repository, please feel free to clone mine.

git clone [email protected]:MasterIfeanyi/ifeanyi-coinnest-html.git
Enter fullscreen mode Exit fullscreen mode

Summary

Now you should be all set up with Git Bash, connected to GitHub.

Thank you, please follow me

HTML GitHub

Top comments (2)

Collapse
 
abdelilah-dev profile image
AbdeLilah Missa

i following the steps above and i show an error if i clone any repo from my personall repo in github why
Image description

Collapse
 
ifeanyichima profile image
Ifeanyi Chima

run this code.

ssh-add ~/.ssh/id_ed25519
Enter fullscreen mode Exit fullscreen mode

and then run this one next

cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more