| How to upload your content to GitHub via Git (Command line via SSH)



What is Git

At the heart of GitHub is an open source version control system (VCS) called Git. Git is responsible for everything GitHub-related that happens locally on your computer.



How to configure Git

  1. First download and install the latest version of Git: https://git-scm.com/downloads
  2. After installing, open Git Bash on the repository to wish to transfer to Github (on windows you can right-click in the repository and open Git Bash or you can use “cd” to change directory).

  3. Git Bash picture
    Git Bash picture
  4. So firstly you need to setup your username and email address.
    1. git config --global user.name "Your name here" and to make sure that you set it up correctly: git config --global user.name
    2. git config --global user.email "your_email@example.com"
    3. Set up SSH on your computer. ssh-keygen -t rsa -C "your_email@example.com" remember the place which you save the key.
    4. Copy the generated SSH key (You might entered the location or it’s on the default location which is where your new user has been created - mine is on C:\Users\unix nexo\.ssh).
    5. Head up to your Github account and go to the Account settings>SSH and GPG Keys>New SSH Key. Paste the SSH key and move on.
    6. To test whether the connection is established or not use this command ssh -T git@github.com if you got a message like the following it means that the connection is good:
    7. - Hi username! You've successfully authenticated, but Github does not provide shell access.


    How to push repository to GitHub (using SSH)

  1. Go to your Github page and create a new Repository by clicking on the New green-button.
  2. Enter the name of your repository. Consider that if you want to host your content like a website on the Github pages you need to name the repository exactly the same name as your Github username and followed by .github.io.
    1. o my username is unixnexo and if I want to host my website I would do this:

    2. Git Bash picture
  3. Then click on Create repository.
  4. Now follow the rest as Github said.

  5. Git Bash picture
  6. Open up the Git Bash on the repository you want to push.
  7. First connect to the SSH: git@github.com:unixnexo/test.git
  8. git init → Every time you want to push a repository you first need to init Git on the repository and you’ll see a hidden folder called .git on your repository.
  9. git branch -M main
  10. git remote add origin git@github.com:unixnexo/test.git
  11. git commit -m "first commit"→ Every time you want to push something you first need commit it and add a comment.
  12. git push -u origin main→ and lastly you push the content.


    How to push the new content

    So for example as you are developing your website you are going to make lots of changes and add new content, so you need to update the Github repository as well.

  1. Just open the Git Bash on your local repository and type git status → this will give you the status of your files.
  2. To add the all new content to your Github repository just type git add . → the “.” here means select all un-pushed items.
  3. Then you need commit the changes and enter a comment by typing git commit -m "something"
  4. Lastly you need to push the following changes by typing git push or git push -u origin main


  • Source: kbroman | github
  • Wrote: November 28, 2022 | Azar 7, 1401
  • Updated:
  • Posted: November 28, 2022 | Azar 7, 1401