π± Introduction to Git & GitHub (Beginner Guide)
This chapter introduces the basics of Git, GitHub, and GitHub Desktop. Youβll learn how version control works and how to manage your code like a professional developer.
π What is Git?
Git is a version control system.
It helps you track changes in your code over time.
Why use Git?
- Save your work history
- Go back to older versions
- Work in teams without overwriting each otherβs code
Basic Git Commands
git init # Start a new Git repository
git status # Check file changes
git add . # Stage all files
git commit -m "message" # Save changes
π What is GitHub?
GitHub is an online platform where you store your Git repositories.
What GitHub is used for:
- Store your projects online
- Share code with others
- Collaborate in teams
- Showcase your portfolio
π₯οΈ What is GitHub Desktop?
GitHub Desktop is a graphical app that lets you use Git without typing commands.
With GitHub Desktop you can: - Commit changes - Push to GitHub - Pull updates - Create branches - Resolve conflicts visually
π Core Git Concepts
β Commit
A commit saves your changes with a message.
Think of it as taking a snapshot of your code.
In GitHub Desktop: 1. Select files 2. Write a message 3. Click Commit to main
β¬οΈ Push
Push sends your local commits to GitHub (online).
In GitHub Desktop:
Click Push origin
β¬οΈ Pull
Pull brings the latest changes from GitHub to your computer.
In GitHub Desktop:
Click Fetch origin β Pull
π Fetch
Fetch checks if new updates exist (without downloading them yet).
In GitHub Desktop:
Click Fetch origin
πΏ Branching (Working on New Features Safely)
A branch is a separate version of your project.
Use branches to: - Add features - Fix bugs - Experiment safely
Common Branch Names
mainβ main projectfeature-loginbug-fix-header
In GitHub Desktop:
- Click Current Branch
- Click New Branch
- Name your branch
- Click Create Branch
π Merging Branches
When your feature is ready, you merge it into main.
In GitHub Desktop:
1. Switch to main
2. Click Branch β Merge into Current Branch
3. Select your feature branch
π§ Typical Workflow (Using GitHub Desktop)
1. Create / Open Repository
2. Make changes
3. Commit
4. Push to GitHub
5. Pull updates from others
6. Create branches for new features
π§ Summary
| Tool / Term | Purpose |
|---|---|
| Git | Tracks code history |
| GitHub | Stores code online |
| GitHub Desktop | Easy Git interface |
| Commit | Save changes |
| Push | Upload to GitHub |
| Pull | Download updates |
| Fetch | Check for updates |
| Branch | Separate feature version |
π Practice Task
- Create a GitHub account
- Install GitHub Desktop
- Create a new repository
- Add a file:
index.html - Commit & Push
- Create a new branch and modify the file