DEV Community

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

Posted on • Edited on

1

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 "barack@gmail.com"
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 "barack@gmail.com"
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 git@github.com: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.

Buy Me A Coffee

Thank you, please follow me

HTML GitHub

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

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

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay