Day 61 – Git Basics


Yesterday, we explored what Git is and why version control matters.
Today, I went deeper into Git basics and branching — the real power of Git for collaborative development.
🔹 Git Basics Recap
Git is a distributed version control system that lets developers:
Track changes in code
Collaborate without overwriting each other’s work
Create separate environments for features, bug fixes, and experiments
🔹 Common Git Commands
Command | Description |
git init | Initialize a new repository |
git clone <url> | Copy a remote repository |
git status | Check repo state |
git add <file> | Stage changes |
git commit -m "message" | Save changes with a message |
git push | Upload changes to remote |
git pull | Get latest changes from remote |
🔹 Understanding Branching
Branching in Git allows you to create a separate line of development without affecting the main project.
It’s like working on a parallel universe of your code until you’re ready to merge back.
🔹 Why Use Branches?
Feature Development – Build new features without touching the main branch
Bug Fixes – Isolate fixes from production code
Experiments – Test ideas safely
Collaboration – Each developer works in their own branch
🔹 Basic Branch Workflow
- Create a branch
git branch feature-login
- Switch to the branch
git switch feature-login
- Or create & switch in one step
git switch -b feature-login
- Work on your changes, commit, and push
git add .
git commit -m "Added login feature"
git push origin feature-login
- Merge branch into main
git checkout main
git merge feature-login
🔹 Branching Strategies
Main/Trunk Based – Keep main always deployable
Feature Branching – One branch per feature
Git Flow – Structured model with
develop
,feature
,release
,hotfix
branches
✅ Takeaway: Branching is the heart of Git’s flexibility, enabling smooth collaboration and risk-free development.
Subscribe to my newsletter
Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
