Skip to main content

Command Palette

Search for a command to run...

Git and GitHub for DevOps

Published
β€’3 min readβ€’View as Markdown
Git and GitHub for DevOps

πŸš€ Conquering Git & GitHub: My Challenge Adventure

πŸ” What is Git and Why Is It Important?

Git is a distributed version control system used by developers to track changes in code over time. It allows multiple people to collaborate on a project without overwriting each other's work. You can roll back to earlier versions of code, work on multiple features simultaneously, and keep everything organized. πŸ’‘

πŸ”§ Why Git Matters in DevOps

In DevOps, Git is absolutely essential because:

  • πŸ› οΈ Automation: CI/CD tools integrate seamlessly with Git to automate testing and deployments.

  • πŸ“¦ Infrastructure as Code: Git stores not just application code, but infrastructure configurations.

  • 🀝 Collaboration: Enables cross-functional teams to develop, test, and deploy code collaboratively.

  • πŸ§ͺ Safe experimentation: Easily create branches, test features, and merge once verified.

πŸ” Git vs GitHub: What’s the Difference?

FeatureGitGitHub
πŸ”„ Tool TypeVersion Control SystemHosting platform for Git repos
πŸ’» LocationRuns locally on your machineCloud-based (GitHub.com)
πŸ” SecurityLocal repository securityOnline collaboration & access control
πŸ‘₯ UsageTracks code historyEnables sharing & team workflows

πŸ’Ό Challenge Tasks Breakdown

βœ… Task 1: Fork & Clone the Repository

  1. I forked the one repository on GitHub.

  2. Cloned it locally using HTTPS:

     git clone <your-fork-url>
     cd 2025/git/01_Git_and_Github_Basics
    

βœ… Task 2: Initialize a Local Repository and Create a File

  1. Created a new folder for the challenge:

     mkdir challenge
     cd challenge
    
  2. Initialized Git:

     git init
    
  3. Created a file called info.txt with my details and added it to Git and committed the changes:

     git add info.txt
     git commit -m "Initial commit: Add info.txt with introductory content"
    

βœ… Task 3: Configure Remote with PAT & Push

πŸ” To simplify authentication (for this exercise only), I configured Git to use a PAT (Personal Access Token):

git remote add origin https://<your-username>:<your-PAT>@github.com/<your-username>/90DaysOfDevOps.git

If origin already exists:

git remote set-url origin https://<your-username>:<your-PAT>@github.com/<your-username>/90DaysOfDevOps.git
  1. Pushed changes to GitHub:

     git push -u origin main
    
  2. Verified everything synced correctly using pull request:

     git pull origin main
    

βœ… Task 4: Explore Your Commit History

πŸ•΅οΈ I checked the commit log to review history and hashes:

git log

This helped me understand the flow of changes and track each commit with confidence.

βœ… Task 5: Advanced Branching & Switching

  1. Created a new feature branch:

     git branch feature-update
     git switch feature-update
    
  2. Edited info.txt with more details, then committed

πŸ” I then opened a Pull Request on GitHub to merge feature-update into main.

πŸ’₯ (Optional) I created an experimental branch to simulate a merge conflict, merged it into feature-update, resolved the conflict manually, and committed the fix.

βœ… Task 6: Branching Strategies Explained

Branching strategies are the backbone of collaborative development. Here's why they matter:

  • 🧩 Isolating Features and Fixes: Branches allow developers to work on features or bug fixes independently without affecting the main code.

  • 🚦 Parallel Development: Multiple developers can work simultaneously using different branches.

  • 🧼 Reducing Merge Conflicts: Proper branch management helps prevent messy conflicts during integration.

  • πŸ‘€ Enabling Code Reviews: Teams can review and test code in branches before merging to production.

πŸ—‚οΈ Common branching strategies include:

  • main or master: Stable production-ready code.

  • dev: Staging area for integration.

  • feature/*: Used for developing new features.

  • hotfix/*: For urgent bug fixes in production.

  • release/*: Prepares code for release.


🏁 Wrapping Up

This Git & GitHub challenge was a great deep dive into real-world version control workflows. From setting up remotes using PATs to branching, merging, and resolving conflicts, I now feel more confident in using Git in a collaborative DevOps environment. πŸ™Œ

More from this blog

DevOps learning

7 posts