Day 2: Mastering Git & GitHub for DevOps
Shruthi Chikkela
Azure Cloud DevOps Engineer | Driving Innovation with Automation & Cloud | Kubernetes | Mentoring IT Professionals | Empowering Careers in Tech ??
?? Welcome to Day 2 of the #100DaysOfDevOps & Cloud challenge!
Yesterday, we introduced DevOps and Cloud—what they are, why they matter, and how they work together. Today, we focus on Git & GitHub, the foundation of modern DevOps practices.
?? What is Git?
Git is a Distributed Version Control System (DVCS) that helps developers track changes in their code, collaborate efficiently, and maintain a history of modifications.
It allows multiple people to work on the same project simultaneously without overwriting each other’s changes.
?? Why Git in DevOps?
In DevOps, continuous integration and continuous deployment (CI/CD) depend on version control.
Git is the go-to tool for:
? Collaboration: Enables multiple developers to work on a project simultaneously.
? Version Control: Tracks code history, making it easy to revert to previous versions.
? Branching and Merging: Allows experimentation without affecting the main codebase.
? Code Backup: Stores code securely in repositories.
? Automation: Triggers CI/CD workflows for automatic testing and deployment.
??? Step 1: Installing Git on Your Local Machine
To start using Git, you first need to install it on your system.
Follow these steps based on your operating system:
?? Windows
git --version
If Git is installed, you’ll see output like:
git version 2.XX.X
?? macOS
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Verify installation:
git --version
?? Linux (Ubuntu/Debian)
sudo apt update && sudo apt install git -y
Verify installation:
git --version
??? Step 2: Configure Git for the First Time
Once Git is installed, configure it with your name and email (this will be used for commit history tracking).
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
To verify your configuration, run:
git config --list
?? How Git Works? (In Layman’s Terms)
?? Imagine a team writing a book together. Instead of using a single document (which leads to confusion), they create separate copies (branches) to write individual chapters.
Once a chapter is complete and reviewed, it is merged into the main book (main branch).
Git works the same way—developers make changes in branches and merge them into the main project.
??? Essential Git Commands & Their Uses
Below are the most important Git commands you should know:
?? What is GitHub?
GitHub is a cloud-based hosting platform for Git repositories.
It enables developers to store, share, and collaborate on code from anywhere.
领英推荐
?? Why GitHub?
? Cloud Storage – Stores Git repositories online.
? Collaboration – Enables multiple people to work on the same project.
? Pull Requests & Code Reviews – Developers can suggest changes before merging.
? Security – Provides access control and security features.
? CI/CD Automation – Integrates with GitHub Actions for automated builds and deployments.
??? Step 3: Creating a GitHub Account & Setting Up Your First Repository
To use GitHub, you need to create an account and set up a repository.
?? Sign Up for GitHub
?? Create Your First Repository
??? Step 4: Connecting Git with GitHub (Pushing Code to GitHub)
Now that Git is installed and a GitHub repository is created, let's connect them.
1?? Initialise a Git repository locally
mkdir my-project
cd my-project
git init
2?? Create a new file and add it to Git
echo "Hello, GitHub!" > README.md
git add README.md
git commit -m "Initial commit"
3?? Link your local repository with GitHub
git remote add origin https://github.com/your-username/my-first-repo.git
git branch -M main
git push -u origin main
?? Real-World Use Case:
In large-scale projects, GitHub helps teams manage software releases.
Developers create feature branches, test them, and merge them into the main branch after review.
?? GitHub Actions – The Future of DevOps Automation
GitHub Actions is an automation tool within GitHub that allows developers to build, test, and deploy applications automatically. It is heavily used in CI/CD workflows.
?? Example CI/CD Workflow with GitHub Actions:
1?? Developer commits code to GitHub.
2?? GitHub Actions triggers automated tests.
3?? If tests pass, GitHub Actions deploys the code to production.
?? This reduces manual work and speeds up software delivery!
?? Layman Example: Git & GitHub in Action
Think of Git as Microsoft Word’s "Track Changes" feature—it records every edit made to a document.
Now, imagine GitHub as Google Drive, where you can store, share, and collaborate on that document with a team.
?? Summary: Why Git & GitHub Are Critical in DevOps?
?? Ensures a structured development process.
?? Enables collaborative coding & review.
?? Forms the backbone of CI/CD pipelines.
?? Reduces the risk of code conflicts & overwriting.
?? What’s Next? Tomorrow, in Day 3, we’ll dive deep into CI/CD Pipelines using GitHub Actions—how they work and how you can set up your first automation!
?? Read the full newsletter & share your thoughts!
?? Follow for daily insights in DevOps & Cloud! ??
?? What’s your experience using Git & GitHub? Have you faced any challenges setting it up? Comment below! ??
?? Follow Shruthi Chikkela for daily insights on DevOps, Cloud, CI/CD, Kubernetes, Terraform, and real-world hands-on projects!
?? Let’s grow together in the #100DaysOfDevOps challenge! ??
AWS Cloud Engineer | Llinux | Windows | Git | Docker | Jenkins | Terraform | K8s |MySQL | MSSQL
3 周I agree
Understanding Git & GitHub is crucial for seamless DevOps workflows. Remember, Git isn't just about version control; it's a powerful collaboration tool driving software development efficiency.
Git and GitHub are indeed the backbone of modern DevOps workflows, enabling seamless collaboration and version control. One key aspect often overlooked is the power of Git hooks for automating tasks like linting or running tests pre-commit.