Skip to main content

Command Palette

Search for a command to run...

Lesson 3 — Git & GitHub Journey

Updated
2 min read
Lesson 3 — Git & GitHub Journey
H
Network Engineer with 3+ years of experience in infrastructure, system administration, and enterprise networking, currently transitioning into DevOps and Cloud Engineering. Hands-on experience with Fortinet firewalls, routers, switches, Windows/Linux servers, and Hyper-V virtualization. Currently building and learning with Docker, Kubernetes, AWS, Linux, CI/CD, GitHub Actions, and automation tools while leveraging MERN stack knowledge to understand the complete application lifecycle from development to deployment. Passionate about cloud infrastructure, automation, containers, and modern DevOps practices. Regularly sharing my learning journey, projects, and hands-on experiments.

Branching in Git

This is one of the MOST important Git concepts.

Branches allow developers to:

  • work safely

  • build features independently

  • avoid breaking main code

  • collaborate in teams

What is a Branch?

Think:

main branch = production code

New feature?

Create separate branch:

feature/login

Work there safely.

Visual Understanding

main
 └── feature/login

Both branches can evolve independently.

1. Check Current Branch

Run:

git branch

You’ll see:

* main  || * master

"*" star means current branch.

2. Create New Branch

git branch feature/login

Now check:

git branch

Output:

* main
  feature-login

Branch exists but not switched yet.

3. Switch Branch

git switch feature-login

Now:

* feature-login
  main

You are inside new branch.

Shortcut Command

Create + switch together:

git switch -c feature-payment

Very commonly used.

4. Make Changes in Branch

Inside feature-login:

echo "Login feature" >> notes.txt

Commit it:

git add .
git commit -m "add login feature"

Important Understanding

That commit exists ONLY in:

feature-login

Not in:

main

5. Switch Back to Main

git switch main

Now open file.

You’ll notice:

login feature line disappeared

Why?

Because commit belongs to another branch.

This is Git magic.

6. Merge Branch

Bring feature into main:

git merge feature-login

Now feature becomes part of main.

Visual After Merge

main
 └── feature-login
        ↓
     merged

7. Delete Branch

After merge:

git branch -d feature-login

Keeps repository clean.

Real Industry Workflow

main
 ├── feature/auth
 ├── feature/payment
 ├── bugfix/header
 └── hotfix/api

Every developer works separately.

8. Merge Conflicts (IMPORTANT)

Conflict happens when:

  • two branches modify same line

Example:

main:
Hello World

feature:
Hello Git

Git cannot decide automatically.

Conflict Example

Git shows:

<<<<<<< HEAD
Hello World
=======
Hello Git
>>>>>>> feature-login

You manually choose final version.

Then:

git add .
git commit

Conflict resolved.

Important Branch Commands

git branch
git switch
git switch -c
git merge
git branch -d

More from this blog

G

Git, GitHub & Workflows Guide – From Basics to Real DevOps Practices

3 posts

Welcome to my learning journey in Git, GitHub, and modern development workflows. This blog documents my hands-on experience, notes, practical examples, and lessons learned while exploring version control, collaboration, branching strategies, pull requests, automation, CI/CD, and DevOps practices. The goal is to build a structured knowledge base that helps both me and other developers learn through real-world examples and continuous practice.