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
- Go to https://github.com
- Click New (or the ”+” icon → “New repository”)
- Fill in:
- Repository name (e.g.
mental-health-workspace) - Description (optional)
- Choose Public or Private
- Repository name (e.g.
- 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.gitReplace 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 pushThat’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