DEV Community

Aditya Singh
Aditya Singh

Posted on

# 🚀 Stop Learning Git Like Commands. Start Thinking Like a Software Engineer.

Today I didn’t just “practice Git.”

I understood how code actually travels from my laptop to production.

If you’re a fresher or junior developer, this mental model will change everything.


1. Git Is Graph Theory, Not File Tracking

Git is a Distributed Version Control System, but internally it’s:

A Directed Acyclic Graph (DAG) of commits.

Each commit:

  • Is immutable
  • Has a parent pointer
  • Stores a snapshot (tree)
  • Has a hash generated from metadata

A branch?

Just a movable pointer.

Once you understand that, push rejections and rebases stop feeling random.


🧠 Merge vs Rebase (Visually)

Image

🔹 Merge

  • Preserves original commits
  • Creates a merge commit
  • Safe for shared branches
  • Non-linear history

🔹 Rebase

  • Replays commits on new base
  • Creates new commit hashes
  • Linear history
  • Dangerous if already pushed

Big realization:

Rebase rewrites history because parent pointers change → new hash generated.

That’s structural. Not magic.


2️⃣ Why Push Gets Rejected (Fast-Forward Concept)

Fast-forward push works when:

Remote branch is ancestor of your local branch.

Git just moves the pointer forward.

If histories diverge?

Push rejected.

Safer fix:

git push --force-with-lease
Enter fullscreen mode Exit fullscreen mode

Always think in terms of commit ancestry, not “who committed last”.


3️⃣ Practical Git Workflow (Industry Style)

Here’s a real feature branch sequence:


🧩 Create Feature Branch

git checkout main
git pull origin main
git checkout -b feature/login-api
Enter fullscreen mode Exit fullscreen mode

✍️ Work & Commit

git add .
git commit -m "Add login controller"
Enter fullscreen mode Exit fullscreen mode

🔄 Sync With Main (Clean Way — Rebase)

git fetch origin
git rebase origin/main
Enter fullscreen mode Exit fullscreen mode

If conflict:

# fix manually
git add .
git rebase --continue
Enter fullscreen mode Exit fullscreen mode

After rebase:

git push --force-with-lease
Enter fullscreen mode Exit fullscreen mode

🔀 Alternative (Merge Instead of Rebase)

git fetch origin
git merge origin/main
git push
Enter fullscreen mode Exit fullscreen mode

No history rewrite. Adds merge commit.


🧠 Minimum Git Command Set Every Fresher Must Know

git branch
git checkout -b <branch>
git add .
git commit -m "message"
git fetch
git merge
git rebase
git push
git push --force-with-lease
git pull --rebase
git log --oneline --graph
Enter fullscreen mode Exit fullscreen mode

If you understand:

  • When to rebase
  • Why push is rejected
  • What fast-forward means

You’re already ahead of most beginners.


4️⃣ What Happens After You Push? (CI/CD Reality)

Your job doesn’t end at git push.

Push triggers a pipeline.

Push → Pipeline → Jobs → Runner → Artifacts
Enter fullscreen mode Exit fullscreen mode

⚙️ GitLab CI Architecture

Image

Image

Image

Key components:

  • .gitlab-ci.yml
  • Pipeline
  • Stages
  • Jobs
  • Runner
  • Artifacts

Important:

  • Stages run sequentially
  • Jobs in a stage run parallel
  • If a job fails → next stage stops

CI is basically:

Event-driven automation triggered by Git events.


5️⃣ Gradle — More Than a Build Tool

Gradle builds a task dependency DAG before running anything.

Two phases:

  1. Configuration phase → builds task graph
  2. Execution phase → runs tasks

If:

Task B dependsOn A
Enter fullscreen mode Exit fullscreen mode

Execution order:

A → B
Enter fullscreen mode Exit fullscreen mode

Everything again… graph-based.


🏗️ Build Flow Visualization

Image

Image

Image

Standard structure:

build.gradle
settings.gradle
src/main/java
src/test/java
Enter fullscreen mode Exit fullscreen mode

🔥 Final Insight From Today

Modern delivery pipeline:

Git Push
   ↓
CI Pipeline Triggered
   ↓
Gradle Build
   ↓
Tests Run
   ↓
Artifact Generated
   ↓
Deployment
Enter fullscreen mode Exit fullscreen mode

You are not just coding.

You are part of a Software Delivery Lifecycle system.


💡 What Changed In My Thinking

  • Git is graph theory.
  • Rebase changes hashes because parent changes.
  • CI is automated event execution.
  • Gradle builds a task DAG before execution.
  • Everything in DevOps is graph + automation.

If you’re a fresher:

Don’t just memorize commands.

Understand:

  • Internal structure
  • Execution flow
  • Why systems behave the way they do

That’s how you move from beginner → engineer.


If you're learning Git, CI/CD, or build systems —
let’s connect and grow together 🚀

Top comments (0)