How to Use GitHub to Store Your First Project

You just finished your first coding project. Maybe it's a calculator, a to-do app, or a personal website. Now what? How do you save it properly, share it with others, or make sure you never lose your work?
The answer is GitHub — the platform where over 100 million developers store, share, and collaborate on code. Whether you're building a portfolio, applying for jobs, or just learning, knowing how to use GitHub is an essential skill.
This guide will walk you through everything from scratch. No prior Git or GitHub experience required.
What You'll Learn:
✅ What Git and GitHub are and why they matter
✅ How to install and configure Git on your machine
✅ How to create your first GitHub repository
✅ How to push your project code to GitHub
✅ How to make changes and track your project's history
✅ Best practices for organizing your repositories
What is Git? What is GitHub?
Before we start, let's clarify two terms that beginners often confuse:
| Term | What It Is | Where It Runs |
|---|---|---|
| Git | A version control system that tracks changes to your files | On your computer (local) |
| GitHub | A cloud platform that hosts Git repositories online | On the internet (remote) |
Think of it this way:
- Git is like the "Save" and "Undo" system for your entire project — but much more powerful
- GitHub is like Google Drive for your code — it stores your project online so you can access it anywhere
Why Should You Use Git and GitHub?
1. Never lose your code again
Your laptop could crash, your hard drive could fail. With GitHub, your code is safely stored in the cloud.
2. Track every change you make
Git remembers every change. Made a mistake? You can go back to any previous version of your code.
3. Build your developer portfolio
Recruiters and hiring managers look at GitHub profiles. Your repositories show what you can build.
4. Collaborate with others
Working on a group project? GitHub makes it easy for multiple people to work on the same codebase.
5. It's an industry standard
Almost every software company uses Git. Learning it now gives you a head start in your career.
Step 1: Install Git
On macOS
Open Terminal and run:
# Check if Git is already installed
git --version
# If not installed, install via Homebrew
brew install gitIf you don't have Homebrew, install it first from brew.sh.
On Windows
Download Git from git-scm.com and run the installer. Use the default settings — they work fine for beginners.
After installation, open Git Bash (it comes with the installer) and verify:
git --version
# Output: git version 2.x.xOn Linux (Ubuntu/Debian)
sudo apt update
sudo apt install git
git --versionStep 2: Configure Git
After installing Git, tell it who you are. This information appears in your commit history:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"Use the same email you'll use for your GitHub account. This links your local commits to your GitHub profile.
Verify your configuration:
git config --global --list
# Output:
# user.name=Your Name
# user.email=your.email@example.comStep 3: Create a GitHub Account
- Go to github.com
- Click Sign up
- Choose a username (this will be your public profile URL:
github.com/your-username) - Use a professional username — recruiters will see this
Tip: Choose a username that's easy to remember and professional. Avoid random numbers or joke names. Something like
chanh-leorjohn-doe-devworks great.
Step 4: Create Your First Repository
A repository (or "repo") is like a folder for your project on GitHub. Let's create one.
Option A: Create on GitHub First (Recommended for Beginners)
- Click the + icon in the top-right corner of GitHub
- Select New repository
- Fill in the details:
| Field | What to Enter | Example |
|---|---|---|
| Repository name | Short, descriptive name using hyphens | my-first-website |
| Description | Brief summary of your project | A personal portfolio website built with HTML and CSS |
| Visibility | Public (anyone can see) or Private | Public |
| Initialize | Check "Add a README file" | ✅ Checked |
| Add .gitignore | Choose your language template | Select based on your project |
- Click Create repository
Understanding .gitignore
A .gitignore file tells Git which files to not track. You don't want to upload:
- Dependencies (
node_modules/,venv/) - Build files (
dist/,build/) - Secrets (
.env, API keys) - OS files (
.DS_Store,Thumbs.db)
GitHub provides templates for common languages. Here's a simple example:
# Dependencies
node_modules/
venv/
__pycache__/
# Environment variables (NEVER commit these!)
.env
.env.local
# Build output
dist/
build/
# OS files
.DS_Store
Thumbs.db
# IDE files
.vscode/
.idea/Step 5: Connect Your Local Project to GitHub
Now let's connect your project on your computer to the GitHub repository.
If You Already Have a Project Folder
Navigate to your project folder in the terminal:
cd ~/my-projects/my-first-websiteInitialize Git in your project:
# Turn this folder into a Git repository
git initConnect it to your GitHub repository:
# Add the remote repository URL
git remote add origin https://github.com/your-username/my-first-website.gitIf You Created the Repo on GitHub First
Clone (download) the repository to your computer:
# Clone the repository
git clone https://github.com/your-username/my-first-website.git
# Navigate into the project folder
cd my-first-websiteThis creates a folder with the repository name and sets up the Git connection automatically.
Step 6: The Git Workflow — Add, Commit, Push
This is the core workflow you'll use every day. Think of it as three steps:
Step 6.1: Check the Status
Always start by checking what's changed:
git statusOutput example:
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
style.css
script.jsStep 6.2: Stage Your Files (git add)
Staging tells Git which files you want to include in your next save point:
# Add specific files
git add index.html style.css
# Or add ALL changed files at once
git add .
git add .adds everything in the current directory. Be careful — make sure you have a.gitignorefile first so you don't accidentally add files you shouldn't.
Step 6.3: Commit Your Changes (git commit)
A commit is a snapshot of your project at a specific point in time. Always include a descriptive message:
git commit -m "Add homepage with navigation bar and hero section"Writing Good Commit Messages:
| ✅ Good Messages | ❌ Bad Messages |
|---|---|
Add login form with email validation | update |
Fix navigation bar not showing on mobile | fix stuff |
Remove unused CSS classes from header | changes |
Add dark mode toggle to settings page | asdfgh |
Commit message tips:
- Start with a verb: Add, Fix, Update, Remove, Refactor
- Keep it under 72 characters
- Describe what you did and why, not how
Step 6.4: Push to GitHub (git push)
Pushing uploads your commits to GitHub:
# First time pushing to a new repository
git push -u origin main
# After the first time, just use
git pushThe -u flag sets the default remote branch, so future pushes only need git push.
The Complete Flow
Here's the full workflow from start to finish:
# 1. Make changes to your files (edit code, add files, etc.)
# 2. Check what changed
git status
# 3. Stage the changes
git add .
# 4. Commit with a message
git commit -m "Add contact form with email validation"
# 5. Push to GitHub
git pushThat's it! These five commands are 90% of what you'll use day-to-day.
Step 7: Making Changes and Tracking History
Making More Changes
After your initial push, the workflow stays the same. Every time you make changes:
# Edit your files...
git add .
git commit -m "Style the footer with flexbox layout"
git pushViewing Your Commit History
See all your past commits:
git log --onelineOutput:
a1b2c3d Style the footer with flexbox layout
e4f5g6h Add contact form with email validation
i7j8k9l Add homepage with navigation bar and hero section
m0n1o2p Initial commitEach commit has a unique ID (like a1b2c3d) that you can use to go back to that version if needed.
Viewing Changes Before Committing
See what you've changed before staging:
# See all unstaged changes
git diff
# See staged changes (ready to commit)
git diff --stagedStep 8: Write a Great README
Your README.md is the first thing people see when they visit your repository. A good README makes your project look professional.
Here's a template:
# Project Name
Brief description of what this project does.
## Demo
[Live Demo](https://your-demo-link.com) (if available)
## Screenshots

## Technologies Used
- HTML5
- CSS3
- JavaScript
## Getting Started
### Prerequisites
- A web browser
- Git installed on your machine
### Installation
1. Clone the repository:
```bash
git clone https://github.com/your-username/project-name.git- Open
index.htmlin your browser
What I Learned
- How to structure HTML pages semantically
- CSS Flexbox and Grid layouts
- DOM manipulation with JavaScript
Author
Your Name - GitHub
## Common Mistakes and How to Fix Them
### Mistake 1: "I committed something I shouldn't have"
If you accidentally committed a file (like `.env`):
```bash
# Remove the file from Git tracking (keeps the local file)
git rm --cached .env
# Add it to .gitignore
echo ".env" >> .gitignore
# Commit the fix
git add .gitignore
git commit -m "Remove .env from tracking and add to gitignore"
git pushWarning: If you pushed secrets (API keys, passwords) to a public repo, consider those secrets compromised. Rotate them immediately, even after removing the file.
Mistake 2: "I messed up my last commit message"
# Fix the most recent commit message (only if NOT pushed yet)
git commit --amend -m "Corrected commit message here"Mistake 3: "I want to undo my last changes"
# Undo changes to a specific file (before staging)
git checkout -- filename.html
# Unstage a file (after git add, before commit)
git reset HEAD filename.htmlMistake 4: "Push is rejected"
This usually happens when the remote has changes you don't have locally:
# Pull remote changes first, then push
git pull origin main
git pushSetting Up SSH Authentication (Optional but Recommended)
Tired of entering your username and password every time you push? Set up SSH:
# 1. Generate an SSH key
ssh-keygen -t ed25519 -C "your.email@example.com"
# 2. Press Enter for default location, then set a passphrase (or leave empty)
# 3. Copy your public key
# On macOS:
cat ~/.ssh/id_ed25519.pub | pbcopy
# On Linux:
cat ~/.ssh/id_ed25519.pub
# (copy the output manually)
# On Windows (Git Bash):
cat ~/.ssh/id_ed25519.pub | clipThen add the key to GitHub:
- Go to Settings → SSH and GPG keys → New SSH key
- Paste your public key
- Click Add SSH key
Now use SSH URLs instead of HTTPS:
# Change remote URL to SSH
git remote set-url origin git@github.com:your-username/my-first-website.gitGit Cheat Sheet
Here's a quick reference for the commands you'll use most:
| Command | What It Does |
|---|---|
git init | Initialize a new Git repository |
git clone <url> | Download a repository from GitHub |
git status | Show changed files and staging status |
git add . | Stage all changed files |
git add <file> | Stage a specific file |
git commit -m "message" | Save staged changes with a message |
git push | Upload commits to GitHub |
git pull | Download latest changes from GitHub |
git log --oneline | Show commit history (compact) |
git diff | Show unstaged changes |
git branch | List branches |
git checkout -b <name> | Create and switch to a new branch |
git remote -v | Show connected remote repositories |
Tips for Organizing Your GitHub Profile
1. Name Repositories Clearly
| ✅ Good Names | ❌ Bad Names |
|---|---|
personal-portfolio-website | project1 |
todo-app-react | test |
python-budget-tracker | asdf |
2. Use Consistent Naming Conventions
Pick one style and stick with it:
kebab-case:my-first-project(most common on GitHub)snake_case:my_first_project
3. Pin Your Best Repositories
On your GitHub profile, you can pin up to 6 repositories. Choose your best work to showcase.
4. Commit Regularly
Don't wait until the entire project is done. Commit small, meaningful changes as you work:
# Morning: Start the header
git add .
git commit -m "Add header with logo and navigation links"
# Afternoon: Style the header
git add .
git commit -m "Style header with responsive flexbox layout"
# Evening: Add the hero section
git add .
git commit -m "Add hero section with background image"This creates a detailed history that shows your progress and thought process.
What's Next?
Once you're comfortable with the basics, explore these topics:
- Branching — Work on features without affecting the main code
- Pull Requests — Propose changes and get code reviews
- GitHub Issues — Track bugs and feature requests
- GitHub Actions — Automate testing and deployment
- Forking — Contribute to other people's open-source projects
Summary
Here's what we covered:
| Step | Action | Command |
|---|---|---|
| 1 | Install Git | brew install git / download from git-scm.com |
| 2 | Configure Git | git config --global user.name "Name" |
| 3 | Create GitHub account | Sign up at github.com |
| 4 | Create a repository | Via GitHub website |
| 5 | Connect local project | git remote add origin <url> |
| 6 | Add, Commit, Push | git add . → git commit -m "msg" → git push |
| 7 | Track changes | git log, git diff, git status |
| 8 | Write a README | Create README.md with project details |
The key takeaway: Git and GitHub are not complicated once you understand the basic workflow. Start with git add, git commit, and git push — that's all you need for your first project. Everything else you can learn as you go.
Your future self (and future employers) will thank you for starting to use GitHub today.
Resources
📬 Subscribe to Newsletter
Get the latest blog posts delivered to your inbox every week. No spam, unsubscribe anytime.
We respect your privacy. Unsubscribe at any time.
💬 Comments
Sign in to leave a comment
We'll never post without your permission.