By the end of this lesson, you will:
:information_source: Info Version control is a system that saves snapshots of your files over time. Think of it as a time machine for your code! It remembers every change you make, so you can go back to any previous version whenever you need to.
With version control, you can:
:information_source: Info GitHub is like a social network for code! It's a website where developers store their projects, share code with others, and work together to build amazing things. Think of it as Google Drive, but specially designed for programming projects.
GitHub offers these awesome features:
:bulb: These are the most important words you'll use when working with GitHub. Learn them well!
Repository (Repo) :file_folder:
A repository is like a special folder for your project that remembers everything:
- Stores your code: All your project files live here
- Tracks history: Remembers every change ever made
- Two types: Local (on your computer) or remote (on GitHub)
Commit :emoji:
A commit is like taking a photo of your project:
- Captures a moment: Saves the current state of your files
- Includes a message: You describe what you changed
- Has a unique ID: Each commit gets its own special code
- Can be undone: Go back if you made a mistake
Clone :emoji:
Cloning is like making a copy of someone else's project:
- Downloads everything: Gets all files and history
- Creates local copy: Puts the project on your computer
- Stays connected: Links to the original on GitHub
- Lets you work: Make changes on your own computer
Benefits of Using GitHub :star2:
Collaboration :emoji:
Work together like a team of superheroes:
- Team coding: Many people can work on the same project
- Easy sharing: Send your code to friends with one click
- Solve conflicts: GitHub helps when two people change the same file
- Stay organized: Know who's working on what
Project Management :clipboard:
Keep your project running smoothly:
- Track issues: Make a list of bugs to fix
- Project boards: Organize tasks like sticky notes
- Set goals: Plan what to build next
- Release versions: Share finished features with users
Code Quality :sparkles:
Make your code the best it can be:
- Get feedback: Friends can review your code
- Auto-testing: Check if your code works automatically
- Catch mistakes: Find errors before they cause problems
- Learn best practices: See how experienced coders work
Security :emoji:
Keep your projects safe:
- Control access: Choose who can see and edit your code
- Verified changes: Know exactly who made each change
- Security checks: Find potential problems automatically
- Safe storage: Your code is backed up in the cloud
Common Git Commands :computer:
note Don't worry about memorizing all these commands right away! Start with the basic ones and learn more as you need them.
These are the commands you'll use most often:
# Start tracking a project with Git
git init
# See what's changed in your project
git status
# Add files to be saved
git add filename.txt # Add one file
git add . # Add all files
# Save your changes with a message
git commit -m "Fixed the bug in my game"
# See the history of your project
git log
Commands for sharing your code online:
# Copy a project from GitHub to your computer
git clone https://github.com/username/repository.git
# Connect your project to GitHub
git remote add origin https://github.com/username/repository.git
# Send your changes to GitHub
git push origin main
# Get updates from GitHub
git pull origin main
Commands for organizing your project:
# Undo changes to a file
git checkout -- filename.txt
# Stop tracking a file
git rm filename.txt
# Rename or move files
git mv oldname.txt newname.txt
Commands to see what's happening:
# See what you've changed
git diff
# See what's ready to commit
git diff --staged
# See a pretty history
git log --oneline --graph
:bulb: Follow these rules to become a Git pro!
- Check first: Always run
git status
before committing- Clear messages: Write commit messages that explain what you did
- Stay updated: Pull before you push to avoid problems
- Small steps: Make many small commits instead of one big one
- Stay synced: Keep your local files up to date with GitHub
Setting Up GitHub Desktop :emoji:️
:information_source: Info GitHub Desktop is a friendly app that makes using Git super easy! No need to remember commands - just click buttons!
Installation Process :emoji:
Getting GitHub Desktop is easy:
- Visit the download page: Go to https://github.com/apps/desktop
- Download the right version:
- Click the big "Download now" button
- Windows users: Get the Windows version
- Mac users: Get the macOS version
Setup Steps :rocket:
Let's get GitHub Desktop running on your computer:
Step One: Install the App
For Windows:
- Find the downloaded .exe file
- Double-click to start installation
- Follow the simple prompts
For Mac:
- Open the downloaded .dmg file
- Drag GitHub Desktop to your Applications folder
- That's it!
Step 2: Launch GitHub Desktop
For Windows:
- Look in your Start menu
- Or check your desktop for the shortcut
For Mac:
- Open your Applications folder
- Click on GitHub Desktop
Step 3: Sign In
- GitHub Desktop will ask you to sign in
- Use your GitHub account
- Don't have one? Click "Create account" and follow the steps!
Cloning a Repository Using GitHub Desktop :emoji:
note Cloning means copying a project from GitHub to your computer so you can work on it!
You have two choices:
https://github.com/username/repository
:information_source: Info Trae IDE is where you'll write and edit your code. Let's open your cloned project!
For Windows:
For macOS:
You have two ways:
:bulb: Tip Now you're ready to start coding! Your project is connected to GitHub and open in Trae IDE.
You've learned how to:
Try these exercises to master GitHub:
Create Your First Repository
Explore a Popular Project
Practice Git Commands
git init
Remember: The best way to learn GitHub is by using it! Don't be afraid to experiment - you can always undo changes or start fresh.