Web Island Agency

How to connect Git to a GitHub account

How to connect Git to a GitHub account
How to connect Git to a GitHub account

If you need to collaborate on your project with other developers or you want to share it with someone, this is a great time to connect your local repository to the remote one. The most popular solutions to storing remote repositories are GitHub, GitLab and Bitbucket. In this article, I’ll show how to connect local git to the GitHub account.

Follow the steps to connect Git to your GitHub account:

  1. Open a terminal and configure your username for your local Git:
    git config --global user.name 'YOUR_NAME'
  2. Set Git email with the command below:
    git config --global user.email 'YOUR@EMAIL'
  3. Generate a new SSH key with the command:
    ssh-keygen -t rsa -b 4096 -C ‘YOUR@EMAIL’
  4. The terminal will prompt Enter a file in which to save the key message. Enter the desired path or just press Enter to save the default file location (recommended).
  5. Enter a secure passphrase. You must remember it! The passphrase is used to ensure an extra level of security in case if someone gains access to your computer.
  6. Add the newly-created key to ssh-agent:
    eval ‘$(ssh-agent -s)’ ssh-add ~/.ssh/id_rsa
  7. Add the SSH key to your GitHub account:
    xclip -sel clip < ~/.ssh/id_rsa.pub.
  8. On the Github, go to Settings > SSH and GPG keys and click the New SSH key button.
  9. Give a descriptive name for your key in the Title field, paste the key from the clipboard (ctrl+v or cmd+v) into the Key field and click the Add SSH key button.

Now you’ve got Git connected to your GitHub account and it’s time to add your project to a GitHub repository.

Join the discussion!

The article is published under the tags

Read more articles related to the topic