DEV Community

Ikegbo Ogochukwu
Ikegbo Ogochukwu

Posted on

Git and GitHub tutorials for Beginners

πŸ”° 1. What is Git?

Git = Version Control System

πŸ‘‰ It helps you:

  • Track changes in your code
  • Go back to previous versions
  • Collaborate with others safely

Think of it like:

β€œGoogle Docs version history… but for code”

Git records every change as a snapshot (commit) ([FreeCodeCamp][1])


🌐 2. What is GitHub?

  • GitHub is a cloud platform that hosts Git repositories
  • It allows:

    • Collaboration
    • Sharing code
    • Team development

πŸ‘‰ Key idea:

  • Git = tool
  • GitHub = online platform using Git ([product.hubspot.com][2])

πŸ—οΈ 3. Core Git Concepts (VERY IMPORTANT)

πŸ“ Repository (Repo)

A project folder tracked by Git

🧾 Commit

A saved snapshot of your work

πŸ“¦ Staging Area

Where you prepare changes before saving

🌿 Branch

A separate version of your project (for new features)

πŸ”€ Merge

Combining branches together


βš™οΈ 4. Basic Git Workflow (The Heart of Everything)

This is the main flow taught in the video:

Step 1: Initialize Git

git init
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Turns your folder into a Git repository


Step 2: Add Files

git add .
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Moves files to the staging area


Step 3: Commit Changes

git commit -m "Your message"
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Saves a snapshot of your work


Step 4: Connect to GitHub

git remote add origin <repo-url>
Enter fullscreen mode Exit fullscreen mode

Step 5: Push to GitHub

git push -u origin main
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Uploads your code online


πŸ”„ 5. Everyday Git Commands

Check status

git status
Enter fullscreen mode Exit fullscreen mode

See history

git log
Enter fullscreen mode Exit fullscreen mode

Download updates

git pull
Enter fullscreen mode Exit fullscreen mode

Upload changes

git push
Enter fullscreen mode Exit fullscreen mode

🌿 6. Working with Branches (Key Skill)

Create a branch

git checkout -b feature-name
Enter fullscreen mode Exit fullscreen mode

Switch branch

git checkout main
Enter fullscreen mode Exit fullscreen mode

Merge branch

git merge feature-name
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Why branches matter:

  • Work on features without breaking main code ([product.hubspot.com][2])

🀝 7. Collaboration Workflow (GitHub Flow)

This is how teams work:

  1. Create branch
  2. Make changes
  3. Push branch
  4. Open Pull Request (PR)
  5. Review
  6. Merge

πŸ‘‰ Pull Request = β€œPlease review my changes”


🧠 8. Mental Model (Very Important)

Think of Git like this:

Working Directory β†’ Staging β†’ Commit β†’ GitHub
Enter fullscreen mode Exit fullscreen mode
  • Working β†’ you edit files
  • Staging β†’ you prepare changes
  • Commit β†’ you save version
  • GitHub β†’ you share it

⚑ 9. Common Beginner Mistakes (From the Video)

  • ❌ Forgetting to git add
  • ❌ Bad commit messages
  • ❌ Working directly on main branch
  • ❌ Not pulling before pushing

πŸš€ 10. Your First Practice Exercise

Try this:

mkdir my-project
cd my-project
git init

echo "Hello Git" > file.txt
git add .
git commit -m "First commit"

# connect to GitHub repo
git remote add origin <your-repo-url>
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

Top comments (0)