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

CommandDescription
git initInitialize a new repository
git clone <url>Copy a remote repository
git statusCheck repo state
git add <file>Stage changes
git commit -m "message"Save changes with a message
git pushUpload changes to remote
git pullGet 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

  1. Create a branch
git branch feature-login
  1. Switch to the branch
git switch feature-login
  1. Or create & switch in one step
git switch -b feature-login
  1. Work on your changes, commit, and push
git add .
git commit -m "Added login feature"
git push origin feature-login
  1. 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.

0
Subscribe to my newsletter

Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shaharyar Shakir
Shaharyar Shakir