What I Wanted to Do
Push a local project to GitHub for the first time.
Steps
1. Create a Repository on GitHub
- Log in to github.com
- Top right ”+” → “New repository”
- Enter a repository name → “Create repository”
2. Initialize Git Locally
git init
git add .
git commit -m "first commit"
3. Connect to GitHub and Push
git remote add origin https://github.com/YOUR_USERNAME/REPO_NAME.git
git branch -M main
git push -u origin main
Common Pitfalls
- If you add a README when creating the repo on GitHub, the first push will cause a conflict
- Password authentication is deprecated — use a Personal Access Token (PAT) or SSH key
Setting up SSH authentication means you never have to type a password. See Generate an SSH Key and Add It to GitHub.
Related Posts
- How to Install Git on Windows and Configure It
- How to Undo a Git Commit
- Git Branch Basics: Create and Switch Branches
- Generate an SSH Key and Add It to GitHub
Recommended Services
- Fiverr - Find freelance developers and tech experts