Master Git & GitHub—collaborate, automate, and level up your DevOps skills for modern success!
Why Git and GitHub Are Non-Negotiable in DevOps
In today’s fast-paced DevOps environments, mastering the basics of git and GitHub isn’t just a nice-to-have. It’s essential. Whether you’re a developer, operator, architect, or any other role in the software delivery pipeline, your ability to collaborate, track changes, and automate workflows depends on these tools. If you’re not using git and GitHub, you’re falling behind.
Every piece of code—whether it’s application logic, Infrastructure as Code (IaC), CI/CD pipelines, or automation scripts—should live in a git repository. Why? Because version control is the backbone of modern software delivery. It enables teams to work together, experiment safely, and recover quickly from mistakes. Without it, collaboration breaks down, and innovation stalls.
- All code—including application logic, Infrastructure as Code (IaC), CI/CD pipelines, and automation scripts—should be stored in a git repository.
- Version control serves as the foundation of modern software delivery.
- It allows teams to collaborate efficiently, experiment with new ideas safely, and recover quickly from errors.
- Without version control, effective collaboration becomes difficult and innovation is hindered.
The Basics: What Is Git?
Git is a distributed version control system. It lets you track changes to files, collaborate with others, and maintain a history of your project. Here are the core concepts:
- Repository (repo): A collection of files and their history. You can create a repo locally or host it on a platform like GitHub.
- Branching: Create a separate line of development to work on features or fixes without affecting the main codebase.
- Merging: Combine changes from different branches. This is how teams bring their work together.
- Push and Pull: Push sends your changes to a remote repository (like GitHub). Pull fetches changes from the remote repo to your local machine.
Why All Code Belongs in Git
- Traceability: Every change is tracked. You know who changed what and when.
- Collaboration: Multiple people can work on the same project without overwriting each other’s work.
- Automation: Tools like GitHub Actions automate testing, deployment, and more.
- Recovery: Mistakes happen. With git, you can roll back to a previous state.
- Experimentation: It’s trivial to create a branch to experiment with.
Git and GitHub: The Power Duo
While git manages your code locally, GitHub provides a cloud-based platform for hosting, sharing, and collaborating on git repositories. GitHub adds features like pull requests, issues, CI/CD, and integrated advanced security.
Git Workflow Components
-
Working Directory
- Definition: The working directory is the local folder on your machine where you actively edit and modify files.
- Purpose: It reflects the current state of your project, including untracked, modified, or deleted files.
- Command Used:
-
- git add: Moves changes from the working directory to the staging area.
-
- git merge or git checkout: Applies changes from the local repository to the working directory.
-
Staging Area (Index)
- Definition: A preparatory space where changes are listed before committing them to the repository.
- Purpose: Allows you to selectively group changes into coherent commits.
- Command Used:
-
- git commit: Records the staged changes into the local repository.
-
Local Repository
- Definition: A hidden “. git” directory on your machine that stores the complete history of commits and branches.
- Purpose: Acts as your personal version control database, independent of any remote server.
- Commands Used:
-
- git push: Sends committed changes to the remote repository.
-
- git fetch or git pull: Retrieves updates from the remote repository.
-
- git merge or git checkout: Integrates or switches to changes from the local repository.
-
Remote Repository
- Definition: A version of your repository hosted on a server (e.g., GitHub, GitLab, Bitbucket) for collaboration and backup.
- Purpose: Enables distributed development by allowing multiple users to share and synchronize code.
- Commands Used:
-
- git fetch: Downloads changes from the remote repository without merging.
-
- git pull: Combines git fetch and git merge to update your local repository.
-
- git push: Uploads your local commits to the remote repository.
Summary of Git Commands in the Diagram
|
Command |
Direction of Flow |
Function |
|
git add |
Working Directory → Staging Area |
Prepares changes for commit |
|
git commit |
Staging Area → Local Repository |
Saves changes to local history |
|
git push |
Local Repository → Remote Repository |
Shares changes with others |
|
git fetch/pull |
Remote Repository → Local Repository |
Retrieves updates from others |
|
git merge/checkout |
Local Repository → Working Directory |
Applies or switches to committed changes locally |
Git Cheat Sheet: Your Quick Start Guide
|
Task |
Command |
Example/Notes |
|
Set up your identity |
git config --global user.name "Your Name" git config --global user.email "you@example.com" |
Sets your global name and email for commits. |
|
Create a new repository |
git init |
Initializes a new local repository. |
|
Clone an existing repository |
git clone [URL] |
Copies a remote repository to your machine.Replace [URL] with the repository address. |
|
Check status of your files |
git status |
Shows changed, staged, and untracked files. |
|
Add files to staging |
git add <filename> |
Stages a file for commit.Replace <filename> with your file name. |
|
Commit your changes |
git commit -m "Describe your change" |
Saves your staged changes with a message. |
|
Create a new branch |
git branch <branch-name>git checkout <branch-name> |
Creates and switches to a new branch.Replace <branch-name> with your branch name. |
|
Merge a branch into main |
git checkout maingit merge <branch-name> |
Switches to main branch and merges another branch into it. |
|
Push changes to remote |
git push origin <branch-name> |
Uploads your branch changes to the remote repository. |
|
Pull changes from remote |
git pull origin main |
Downloads and integrates changes from the remote main branch. |
Sample command-line usage:
# Set up your identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
# Create a new repository
git init
# Clone an existing repository
git clone https://github.com/owner/repo.git
# Check status of your files
git status
# Add file(s) to staging
git add <filename>
# Commit your changes
git commit -m "Describe your change"
# Create a new branch
git branch <branch-name>
git checkout <branch-name>
# Merge a branch into main
git checkout main
git merge <branch-name>
# Push changes to remote
git push origin <branch-name>
# Pull changes from remote
git pull origin main
For a more detailed cheat sheet, check out: GitHub’s official guide.
Call to Action: Level Up Your DevOps Game
Don’t wait—start learning git and GitHub today. These skills will make you a better collaborator, a more effective problem solver, and a key contributor to any DevOps team. Explore more with these resources:
Act now! Your next project, your team, and your career will thank you.
Now it’s your turn
I would love to know in the comment what has been your experience with git. What have you found useful for your project? What challenges have you experienced?
About the author
Jean-François Bilodeau, or J-F, brings over 30 years of experience in the tech industry, starting as a developer for anti-virus companies before moving into game development and technical training. An award-winning game developer and trainer, he is now a Microsoft employee passionate about empowering every person and organization on the planet to achieve more. Fluent in French and English, J-F combines technical expertise in development, classroom training, and AI with a mission to share his passion for learning.