GitUploading to GitHub

Uploading to GitHub Using Git

After creating commits locally using Git, you can upload your project to GitHub to:

  • Back up your code online
  • Share it with others
  • Collaborate with teammates

Step 1: Create a GitHub Repository

  1. Go to https://github.com
  2. Click New (or the ”+” icon → “New repository”)
  3. Fill in:
    • Repository name (e.g. mental-health-workspace)
    • Description (optional)
    • Choose Public or Private
  4. Click Create repository

❗ Don’t initialize with a README if you’re pushing an existing local repo.


Step 2: Add the Remote Origin

In your terminal:

git remote add origin https://github.com/your-username/mental-health-workspace.git

Replace your-username with your GitHub username.


Step 3: Push Code to GitHub

Initial push:

git branch -M main
git push -u origin main

💡 -u sets the upstream so future pushes can use just git push


Step 4: Make Future Changes

Whenever you make changes later:

git add .
git commit -m "Update some files"
git push

That’s it! Your changes are now live on GitHub.


GitHub Authentication

If prompted for login:

  • You may need to generate a Personal Access Token (PAT) if you’re using HTTPS
  • GitHub PAT guide

Try It Yourself

Problem 1: Upload Your Local Project

Show Code
cd my-project
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/your-username/my-project.git
git branch -M main
git push -u origin main