Git & GitHub: The Backbone of Modern DevOps

M ChidrupM Chidrup
4 min read

What is Git?

Git is a distributed version control system created by Linus Torvalds in 2005. It allows developers to track changes in source code, collaborate on projects, and revert to previous versions if needed.

Git stores the entire repository history on each developer’s machine – making it robust and fast.


☁️ What is GitHub?

GitHub is a cloud-based hosting platform for Git repositories. It provides a web interface, tools for pull requests, issue tracking, CI/CD integration, and collaboration features that supercharge software development.


🧭 Centralized vs Distributed Version Control

FeatureCentralized (e.g., SVN)Distributed (Git)
Repo LocationSingle central serverLocal + remote copy
Offline Work❌ No✅ Yes
PerformanceSlowerFaster
Risk of Data LossHigh (single point of failure)Low
CollaborationNeeds constant server connectionMore flexible

🍴 Why Fork Repositories?

Forking is creating a copy of someone else's repository in your own GitHub account.

Why fork?

  • Work on open-source projects independently.

  • Submit changes via pull requests.

  • Experiment with ideas without affecting the original code.

Example: Contributing to facebook/react starts by forking the repo.


💻 Essential Git & GitHub Commands

TaskCommand
Clone a repogit clone https://github.com/user/repo.git
Stage changesgit add . or git add <file>
Commitgit commit -m "Message"
Pushgit push origin main
Pullgit pull origin main
Check statusgit status
Create branchgit checkout -b feature-xyz
Switch branchgit checkout main
Merge branchgit merge feature-xyz
Resolve conflictsManual edit + git add + git commit

🌿 Why Git Branching Strategy Matters

Branching allows parallel development without affecting the main codebase. Common strategies:

  1. Git Flow

    • main, develop, feature/*, release/*, hotfix/*
  2. GitHub Flow

    • Simple model: branch from main, create PRs
  3. Trunk-based Development

    • Small, frequent commits to main, ideal for CI/CD

Benefits:

  • Organized workflow

  • Reduces merge conflicts

  • Facilitates CI/CD pipelines

  • Enables better collaboration

What is the difference between Git and GitHub?

Git is a distributed version control system that tracks changes in code across developers and time. GitHub is a web-based platform that hosts Git repositories and offers collaboration features like pull requests, code reviews, and CI/CD integration.


How does Git ensure data integrity?

Git uses SHA-1 hash functions to name and identify every object (commits, trees, blobs). This ensures the data hasn’t been altered and maintains the integrity of the codebase.


Explain the Git lifecycle (Working Directory → Staging Area → Repository).

  • Working Directory: Where you modify files.

  • Staging Area: Temporary area where you prepare changes using git add.

  • Repository: Final, committed changes are saved using git commit.
    This separation gives fine-grained control over what changes to track and commit.


What is a merge conflict? How do you resolve it?

A merge conflict occurs when two branches modify the same part of a file differently, and Git cannot decide which change to keep.
To resolve:

  1. Manually edit the conflicted files.

  2. Mark the resolved changes.

  3. Stage with git add.

  4. Commit the resolution.


What is the difference between git pull and git fetch?

  • git fetch: Downloads updates from the remote repo but does not merge them.

  • git pull: Does a fetch followed by an automatic merge into your current branch.


What is a fork and how is it different from a clone?

A fork creates a copy of a repo on GitHub under your account — used for contributing to other projects.
A clone is a local copy of any Git repository (yours or someone else's), used for development.


Why is branching important in DevOps workflows?

Branching allows isolation of features, bug fixes, and experiments without affecting the main codebase. It enables collaboration, parallel development, and continuous integration in pipelines, reducing conflicts and downtime.


What are best practices for writing commit messages?

  • Use present tense: "Fix bug" not "Fixed bug"

  • Keep the subject line under 50 characters

  • Include a detailed body if needed

  • Reference issues or tickets (e.g., Fixes #42)


Have you used any Git branching strategies in a team? Explain.

Yes. I’ve used GitHub Flow and Git Flow. In GitHub Flow, we create a branch from main, push changes, and open a pull request for review. For larger projects, Git Flow helps manage features, releases, and hotfixes using structured branches like develop, feature/*, and release/*.


How do you revert a commit in Git?

  • Use git revert <commit> to undo a commit safely by creating a new one that negates it.

  • Use git reset (soft/hard/mixed) to remove commits from history (not recommended for shared branches).

0
Subscribe to my newsletter

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

Written by

M Chidrup
M Chidrup

Certified Azure Cloud Enthusiast and Full Stack Developer with a strong foundation in building secure, scalable cloud-native applications. Passionate about integrating AI and automation in DevOps pipelines and exploring intelligent cloud systems. I specialize in React, Node.js, Azure, Kubernetes, and DevSecOps, and I love solving real-world problems through code, collaboration, and continuous learning.