This guide explains how to connect your local code to GitHub repositories, using simple terms and practical examples. Perfect for beginners who are new to version control!
Think of Git as a smart diary for your code:
- 📝 Tracks every change you make to your files
- 🕰️ Remembers history - you can see what changed and when
- 🔄 Allows you to go back to any previous version
- 👥 Helps teams work together without overwriting each other's work
Think of GitHub as a library in the cloud:
- 📚 Stores your code online safely
- 🌐 Makes it accessible anywhere with internet
- 👥 Lets others see and contribute to your projects
- 🔄 Syncs with your local Git diary
- Your computer = Your personal workspace
- Git = Your personal diary of changes
- GitHub = Public library where you store copies of your diary
| Term | Simple Explanation | Real Example |
|---|---|---|
| Repository (Repo) | A project folder with Git tracking | Your "ParkerHub" folder |
| Commit | Saving a snapshot of your changes | "Added login feature" |
| Push | Uploading your changes to GitHub | Sending your diary to the library |
| Pull | Downloading changes from GitHub | Getting updates from the library |
| Branch | A separate version to work on | "main" (stable) vs "testing" (experimental) |
| Clone | Making a copy of a GitHub repo locally | Downloading someone's project |
| Fork | Making your own copy of someone's repo | Taking a book to write your own version |
You wrote code on your computer and want to put it on GitHub.
You want to work on an existing GitHub project.
# Check if Git is installed
git --version
# If not installed, download from: https://git-scm.com/# Set your name (use your real name)
git config --global user.name "Your Full Name"
# Set your email (use your GitHub email)
git config --global user.email "your.email@example.com"
# Verify your settings
git config --list | grep user- Go to GitHub.com → Settings → Developer settings → Personal access tokens
- Generate new token with "repo" permissions
- Copy the token (save it somewhere safe!)
# Generate SSH key
ssh-keygen -t rsa -b 4096 -C "your.email@example.com"
# Add to GitHub: Settings → SSH and GPG keys → New SSH key- Go to GitHub.com
- Click green "New" button
- Enter repository name (e.g., "MyProject")
- Choose Public or Private
- DON'T check "Add a README file" (since you have local code)
- Click Create repository
# Navigate to your project folder
cd "C:\path\to\your\project"
# Initialize Git (creates .git folder)
git init
# Check status
git status# Create .gitignore file to exclude unnecessary files
# For Python projects:Create .gitignore file with this content:
# Python
__pycache__/
*.py[cod]
*.so
*.egg-info/
dist/
build/
# Virtual Environment
venv/
env/
ENV/
# IDE
.vscode/
.idea/
*.swp
# OS
.DS_Store
Thumbs.db
# Database
*.sqlite3
*.db
# Logs
*.log
# Environment variables
.env# Add all files to staging area
git add .
# Check what will be committed
git status
# Create your first commit
git commit -m "Initial commit: Add project files"
# Verify the commit
git log --oneline# Add GitHub repository as remote origin
git remote add origin https://github.com/YourUsername/YourRepoName.git
# Verify remote was added
git remote -v
# Push your code to GitHub
git push -u origin mainIf you get authentication error:
# Use token authentication
git remote set-url origin https://YourUsername:YourToken@github.com/YourUsername/YourRepoName.git# Clone repository to your computer
git clone https://github.com/Username/RepoName.git
# Navigate into the cloned folder
cd RepoName
# Check the status
git status# Make your changes to files
# Then add them to staging
git add .
# Commit your changes
git commit -m "Describe what you changed"
# Push to GitHub
git push# 1. Check current status
git status
# 2. Add changes to staging
git add . # Add all changes
git add filename.txt # Add specific file
# 3. Commit changes
git commit -m "Meaningful message describing changes"
# 4. Push to GitHub
git push
# 5. Get latest changes from GitHub
git pull# See commit history
git log --oneline
# See what changed in files
git diff
# See branches
git branch
# See remotes
git remote -v# See all branches
git branch -a
# Create new branch
git checkout -b feature-name
# Switch to existing branch
git checkout main
# Merge branch into current branch
git merge feature-name
# Delete branch (after merging)
git branch -d feature-name
# Push new branch to GitHub
git push -u origin feature-name# 1. Start from main branch
git checkout main
git pull
# 2. Create feature branch
git checkout -b add-login-feature
# 3. Work on your feature, make commits
git add .
git commit -m "Add login form"
# 4. Push feature branch
git push -u origin add-login-feature
# 5. Create Pull Request on GitHub
# (Done through web interface)
# 6. After PR is merged, clean up
git checkout main
git pull
git branch -d add-login-featureSolution: You're not in a Git-initialized folder
git initSolution: Remote has changes you don't have locally
git pull origin main
# Resolve any conflicts, then:
git pushSolution: Set up authentication properly
# Use token in URL
git remote set-url origin https://username:token@github.com/username/repo.gitSolution: Configure Git user info
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"# Remove file from staging (before commit)
git reset filename.txt
# Remove file from last commit (after commit)
git reset --soft HEAD~1| Command | Purpose | When to Use |
|---|---|---|
git init |
Start Git tracking | New project |
git clone <url> |
Copy repo from GitHub | Starting with existing repo |
git status |
See current state | Check before committing |
git add . |
Stage all changes | Before committing |
git commit -m "msg" |
Save snapshot | After making changes |
git push |
Upload to GitHub | Share your work |
git pull |
Download from GitHub | Get latest changes |
git log --oneline |
See history | Review what happened |
git branch |
List branches | See all branches |
git checkout -b name |
Create new branch | Start new feature |
# 1. Create project folder
mkdir MyNewProject
cd MyNewProject
# 2. Initialize Git
git init
# 3. Create .gitignore (copy from above)
# 4. Add your project files
# 5. Make first commit
git add .
git commit -m "Initial commit"
# 6. Create GitHub repo (through website)
# 7. Connect and push
git remote add origin https://github.com/username/MyNewProject.git
git push -u origin main# 1. Clone repository
git clone https://github.com/username/project.git
cd project
# 2. Make changes
# 3. Commit and push
git add .
git commit -m "Your changes"
git push- Understand Git vs GitHub
- Know basic commands
- Can commit and push code
- Can clone repositories
- Work with branches confidently
- Understand merge conflicts and how to resolve them
- Use pull requests for collaboration
- Understand
.gitignorepatterns
- Rebase vs merge strategies
- Git hooks and automation
- Advanced branching strategies (Git Flow)
- Contributing to open source projects
Let's practice with your actual repository:
# 1. Navigate to your project
cd "C:\Users\akash\OneDrive\Desktop\coding\ParkerHub"
# 2. Check status
git status
# 3. Make a small change (add a comment to a file)
# 4. Commit the change
git add .
git commit -m "Add practice comment for Git learning"
# 5. Push to GitHub
git push
# 6. Check GitHub to see your change!- Interactive Git Tutorial: https://learngitbranching.js.org/
- GitHub's Git Handbook: https://guides.github.com/introduction/git-handbook/
- Visual Git Reference: https://marklodato.github.io/visual-git-guide/index-en.html
- Pro Git Book (Free): https://git-scm.com/book
- Commit often - Small, frequent commits are better than large ones
- Write good commit messages - Describe WHAT and WHY, not HOW
- Use branches - Don't work directly on main for new features
- Pull before push - Always get latest changes first
- Backup important work - GitHub IS your backup!
Remember: Everyone was a beginner once. Don't be afraid to experiment - Git makes it very hard to permanently lose your work! 🎉
Created: September 20, 2025
For: Complete Git & GitHub beginners
Author: Based on ParkerHub project experience