DEV Community

Neal Onyango
Neal Onyango

Posted on

PUSHING FOLDERS TO GITHUB USING SSH

Introduction

Pushing is the process of uploading a folder saved on a local repository to an online repository which can be accessed remotely. The online repository may be public or private. This article is an explanation of the step by step process of how to push projects from your local folder to GitHub on windows operating system. We shall use GitBash to write command line language and SSH key to link our GitHub to GitBash.

Prerequisites

  • Log in to your GitHub account
  • Download GitBash
  • Correctly configure GitBash by running the command git config —-global —-list

Setup your SSH key.

  1. Open GitBash and generate a new SSH key, replacing the email with the one linked to your GitHub account using the command ssh-keygen -t ed25519 -C “email”
  2. confirm the key was created using ls -al ~/.ssh
  3. To see the SSH key using cat ~/.ssh/id_ed25519.pub and then copy it
  4. On GitHub, go to Settings then SSH where you will select new SSH key. Give it a title and paste your public key into the key field
  5. Test the connection on GitBash using ssh -T git@github.com

Push Process

  1. Confirm your current working directory by running the command pwd
  2. Use the command ls -la to see all files hidden and non-hidden files.
  3. If you are not in the directory of the folder you are looking for, use the command cd to move until the correct directory.
  4. Initialize the directory a GIT repository so GIT may begin managing the project using the command git init
  5. Stage your file so Git starts tracking using the command git add .
  6. Commit the staged files with a message describing the changes using git commit -m “description
  7. Create an empty GitHub repository, name the repository, leave README unchecked and then choose SSH as your connection option.
  8. Copy the SSH repository address and then on GIT bash, type the command git remote add origin pasted SSH repository address
  9. Confirm the remote is correct using the command git remote -v
  10. You can now push the project using git push -u origin main
  11. Refresh the repository page on GitHub to see your pushed folder

Conclusion

This is the entire workflow of pushing a local project to GitHub using SSH on Windows. This is the cycle which you will repeat for every change you make.

Top comments (0)