How To Push Your Code To GitHub from your Local or Remote Server

If you have a project that is already running on a remote server or on your local machine and you would like to move your code to GitHub here are the steps.

  1. Log into GitHub and create an empty git repository.
    Make sure you do not initialize the repository with a README, gitignore or license.
  2. Copy the SSH repository link
  3. On your server/local terminal type
    git remote add origin git@github.com/account-name/repository-name.git
  4. Check that this was added successfully by typing:
    git remote -v
    This should have an output silimar to this:
    origin origin git@github.com/account-name/repository-name.git (fetch)
    origin origin git@github.com/account-name/repository-name.git (fetch)
  5. Now run the following command
    git push origin main
    This should generate a few lines in the terminal containing
    Writing objects: 100%
  6. Check your GitHub Repo to visually confirm that the repo was pushed

Published
Categorized as GitHub Tagged

Leave a comment

Your email address will not be published. Required fields are marked *