Level 1: Git Basics
👋 Welcome, Developer!
Congratulations on embarking on this journey to master the powerful tools of Git and GitHub. To make it fun and digestible, we’ve designed this guide like a game—each level brings you closer to becoming a Git Guru! Let's jump into Level 1, where you'll unlock the foundations of version control.
🧩 What’s the difference between Git and GitHub?
Imagine you're writing a novel:
Git is like your editor: it tracks all the changes, suggests improvements, and helps you jump back to any earlier version.
GitHub is like the library where the final novel (and its drafts) are stored. It’s an online platform for collaboration, sharing, and storing code.
In short:
Git = Version Control Tool (local).
GitHub = Cloud-based Repository for sharing (remote).
🕹️ What is Version Control?
Think of it like a “save game” feature in your favorite video game:
🕑 You can save your progress at different stages.
🔄 If something goes wrong, you can reload an earlier save.
🤝 You and your team can work on different levels without messing up each other's progress.
🛠️ Step 1: Download Git
For Windows
Go to the Git official website.
Click the "Download for Windows" button.
Run the installer and follow the default settings (or customize them if you're feeling adventurous).
For Mac
Install Xcode Command Line Tools by running:
xcode-select --install
Or, download Git directly from git-scm.com.
For Linux
Use your package manager:
Debian/Ubuntu:
sudo apt install git
Fedora:
sudo dnf install git
🛡️ Step 2: Configure Git
After installation, tell Git who you are. Run these commands in the terminal (replace with your info):
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
🏁 Checkpoint: Use this to check your configuration:
git config --list
If you see your name and email, you’re good to go!
🌐 Step 3: Create a GitHub Account
Go to GitHub.
Click Sign Up.
Fill in your details, choose a strong password, and verify your email.
Customize your profile with a cool avatar (optional but fun)!
Level 2: Terminology and Git Flow
👋 Welcome to Level 2, Developer!
You've mastered the basics; now it's time to solidify your skills. This level covers essential Git commands and concepts in a short and concise way—a perfect recap for new team members.
🧩 Key Terminology
1. Git Basics
Check Git Version:
git --version
Check Repo Status:
Shows tracked/untracked changes:git status
Your Git Config:
Verify name and email settings:git config --list
2. Create & Manage a Repository
Initialize a New Repo:
git init
Git Flow (Working to GitHub):
Edit Files (Working Directory - Untracked):
Update files in your project folder.Stage Changes (Staging Area):
Add files to the staging area:git add <filename>
Or add all changes:
git add .
Commit Changes (Local Repo):
Save your changes with a message:git commit -m "Your commit message"
Push Changes (GitHub):
Send your changes to GitHub:git push origin main
3. Logs and History
View Commit History:
git log
Shorter view:
git log --oneline
4. Editor Settings
Change Default Code Editor:
Use VS Code for Git commit messages:git config --global core.editor "code --wait"
5. Ignore Files
Create
.gitignore
file to exclude unnecessary files like:node_modules .env .vscode
6. Sync with GitHub
Push Changes (to GitHub):
git push
Pull Updates (from GitHub):
git pull
🔗 Cloning the ChaiCode Repository
Clone Command (📥):
Copy a repo from GitHub to your local system:git clone <repository-url>
Navigate into the Folder (📂):
Move into the cloned repo directory:
cd <repository-name>
🛠️ Optional: Git Behind the Scenes
.git
folder is Git's brain, storing everything about your repository. It uses three key objects: Blob for file contents, Tree for folder structure, Commit for snapshots linking changes and history. These objects live in .git/objects
, making Git efficient by storing changes as snapshots, not whole files! 🚀Level 3: Branches and Merges
👋 Welcome to Level 3, Developer!
You’re now entering the exciting world of branches and merges. This level covers how to manage branches, their flow in a company like ChaiCohort, and merging techniques for smooth collaboration.
🧩 Branch Flow at ChaiCohort
Here’s ChaiCohort organize branches:
main
(Stable Branch):The stable version of the code.
Used for deployments and production-ready code.
development
(Testing Branch):Contains changes being tested or prepared for the main branch.
Developers merge their completed work here before production.
Feature or Employee Branches:
Created for individual features, tasks, or experiments.
Example:
feature-login
orjohn-task-42
.Keeps work isolated until it’s ready to integrate.
🔨 Creating and Switching Branches
Check Existing Branches:
git branch
Create a New Branch:
git branch <branch-name>
Switch to a Branch:
git checkout <branch-name>
Or use the shortcut:
git switch <branch-name>
Create and Switch Simultaneously:
git checkout -b <branch-name>
Or:
git switch -c <branch-name>
🔄 Merging Branches
Switch to the Target Branch:
(e.g., Merge a feature branch intodevelopment
)git checkout development
Merge the Branch:
git merge <branch-name>
Resolve Conflicts (if any):
Git marks conflicts in files.
Edit the files, remove conflict markers (
<<<<
,====
,>>>>
).Add the resolved files:
git add <filename>
Complete the merge:
git commit
Level 4: Writing Good Commit Messages
👋 Welcome to Level 4, Developer!
Writing great commit messages is like leaving a clear trail of breadcrumbs for your team. At ChaiCohort, commit messages help us stay aligned, efficient, and collaborative. Let’s explore how to craft them with a personal touch for our community.
🖋️ Rules for Writing Great Commit Messages at ChaiCohort
Use Present Tense 🕰️
Write as if you're describing what the commit does now, not what you already did.
✅ "Add login feature"
🚫 "Added login feature"
Capitalize the First Letter 📌
- Every commit message should look polished.
Keep It Short and Sweet 💬
Limit to 50 characters or fewer for the summary line.
Additional details can go in the description if needed.
Use Meaningful Prefixes (Personalized for ChaiCohort) 🔑
Prefixes categorize commits for better readability. Examples:feat:
For adding new features:
feat: Add user authentication
fix:
For bug fixes:
fix: Resolve login page crash
refactor:
For improving code without changing functionality:
refactor: Simplify login logic
docs:
For documentation updates:
docs: Update README with setup instructions
test:
For adding or updating tests:
test: Add tests for authentication
style:
For formatting changes (no logic changes):
style: Fix indentation in Login.js
Use "Why" and "What" When Necessary 💡
Provide context when making significant changes.
Example:
feat: Add API integration for user data Why: To enable data synchronization with the backend What: Added Axios for requests, created API service.
🔨 Example Commit Messages for ChaiCohort
For a New Feature
✅ feat: Add user profile page
For Fixing a Bug
✅ fix: Resolve issue with data loading on dashboard
For Improving Code Structure
✅ refactor: Modularize utility functions
Level 5: Pull Requests (PRs)
👋 Welcome to Level 5, Developer!
You’ve mastered branches, commits, and merges—now it’s time to learn about Pull Requests (PRs). PRs are how we share, review, and merge our changes into shared branches like main
or development
. Let’s simplify the process!
🛠️ What is a Pull Request (PR)?
A Pull Request is a way to:
Propose your changes to be added to a shared branch (like
main
ordevelopment
).Start a conversation with your team about your code.
Request a review to ensure the code is high quality and aligned with the project.
🔨 How to Create a Pull Request on GitHub
Push Your Changes to GitHub:
After committing your changes locally, push your branch:git push origin <branch-name>
Go to Your Repository on GitHub:
You’ll see a notification: "Compare & pull request." Click it.
Or go to the Pull Requests tab and click New Pull Request.
Select Branches:
Choose your feature branch as the source.
Choose the branch you’re merging into (e.g.,
development
) as the target.
Write a PR Title and Description:
Title: Short and meaningful, like your commit messages.
Example:feat: Add user registration feature
Description:
What did you do? (e.g., "Added registration functionality using a new API.")
Why did you do it? (e.g., "Needed for user onboarding.")
How to test it? (e.g., "Go to
/register
and complete the form.")
Request a Code Review:
Add reviewers from your team to ensure the changes meet standards.
Tag specific people if your work depends on their input.
Submit the PR:
Click Create Pull Request and wait for feedback!
📝 ChaiCohort PR Guidelines
Be Clear and Concise:
- Make it easy for reviewers to understand what your changes do and why.
Follow the Template:
ChaiCohort’s PR template ensures consistency. Example format:What: Summary of the changes.
Why: Why the change was needed.
How to Test: Steps to verify it works.
Request Reviews Promptly:
Always request feedback from relevant teammates early to avoid delays.Fix Feedback Quickly:
Address comments from reviewers promptly and update your PR.
Congratulations, Developer!
You’ve completed your onboarding journey through Git and GitHub essentials at ChaiCohort. Here’s a final checklist of Best Practices to keep you and the team productive and conflict-free.
🛡️ Best Practices for Git & GitHub at ChaiCohort
Commit Regularly:
Small, frequent commits make it easier to track progress, debug issues, and collaborate effectively. Avoid large, monolithic commits that bundle unrelated changes.
Use Descriptive Commit Messages:
Commit messages should clearly explain what was changed and why. Follow the ChaiCohort Commit Message Guidelines from Level 4 to keep our history clean and meaningful.
Pull Updates Regularly:
Before starting new work or committing changes, always pull the latest updates from your branch:
git pull origin <branch-name>
This helps prevent merge conflicts and keeps your work in sync with the team.
Your Git and GitHub journey at ChaiCohort is just getting started, and you’re now equipped to work smarter, code faster, and collaborate like a pro! 🎉