Welcome to the third article in our DevOps From Scratch series! After covering the fundamentals of DevOps and CI/CD pipelines, it's time to dive into one of the most essential tools in any developer's toolkit: Git. If you're serious about DevOps, mastering Git isn't optionalβit's absolutely necessary.
Why Git Matters in the DevOps World
If you've spent even a day in tech, you've probably heard someone mention Git. But what makes it so special?
Git is a distributed version control system that tracks changes to your code over time. Unlike older systems, Git gives each developer their own complete copy of the repository. This means you can work offline, commit changes locally, and sync up when you're ready.
In DevOps environments, where continuous integration and delivery are king, Git provides the foundation that makes collaboration possible without chaos. When multiple team members are working on the same codebase, Git helps prevent them from accidentally overwriting each other's work.
Git Basics: Understanding the Core Concepts
Before we get our hands dirty with commands, let's get familiar with some key Git concepts:
- Repository (Repo): The folder containing your project and the hidden
.gitdirectory that tracks all changes - Commit: A snapshot of your files at a specific point in time
- Branch: A separate line of development that lets you work on features without affecting the main codebase
- Merge: The process of combining changes from different branches
- Clone: Creating a local copy of a remote repository
- Push/Pull: Sending your changes to or retrieving changes from a remote repository

Getting Started: Installing and Setting Up Git
Let's start by getting Git installed on your machine:
For Windows:
- Download the installer from git-scm.com
- Run the installer, accepting default options is usually fine
- Look for Git Bash in your Start menu after installation
For Mac:
brew install git
Or download from the Git website if you don't use Homebrew.
For Linux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install git
Once installed, you'll need to configure Git with your identity:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
This information will be attached to every commit you make, so your team knows who did what.
Creating Your First Git Repository
Now let's create a simple project and initialize Git:
- Create a new folder for your project:
mkdir my-first-git-project
cd my-first-git-project
- Initialize Git:
git init
- Create a simple file:
echo "# My First Git Project" > README.md
- Check the status of your repository:
git status
You should see that README.md is listed as an untracked file. This means Git sees the file but isn't tracking changes to it yet.
The Git Workflow: Add, Commit, Push
The basic Git workflow follows these steps:
1. Track files with git add
git add README.md
Or to add all files:
git add .
2. Commit your changes
git commit -m "Initial commit with README file"
The -m flag lets you add a message describing your changes. Always make these messages clear and descriptive!
3. View your commit history
git log
This shows all commits, starting with the most recent.

Branching: Git's Superpower
Branching is where Git really shines. It allows you to create separate lines of development without affecting your main codebase.
Creating a new branch:
git branch feature-login
git checkout feature-login
Or the shorthand:
git checkout -b feature-login
Now you can make changes on this branch without affecting the main branch (usually called main or master).
Switching between branches:
git checkout main
Merging changes back:
After completing work on your feature branch, you'll want to merge those changes back to the main branch:
git checkout main
git merge feature-login
Dealing with Merge Conflicts
When Git can't automatically merge changes (usually because the same lines were edited in different branches), you'll encounter a merge conflict. Don't panic! This is normal.
Git will mark the conflicts in your files, and you'll need to manually edit them to resolve the conflicts:
<<<<<<< HEAD
This is the content from the current branch
=======
This is the content from the branch you're merging in
>>>>>>> feature-branch
Edit the file to keep the changes you want, remove the conflict markers, then:
git add <file-with-resolved-conflict>
git commit -m "Resolved merge conflict"
Working with Remote Repositories
So far, we've only worked locally. Let's connect to a remote repository like GitHub, GitLab, or Bitbucket.
Adding a remote:
git remote add origin https://github.com/yourusername/your-repo-name.git
Pushing your changes:
git push -u origin main
The -u flag sets up tracking, so in the future, you can simply type git push.
Cloning an existing repository:
git clone https://github.com/someuser/some-project.git
This creates a local copy of the repository, complete with all its history.
Advanced Git Techniques
Once you're comfortable with the basics, you can explore more advanced Git features:
Stashing changes:
Need to switch branches but aren't ready to commit? Stash your changes:
git stash
And later, retrieve them:
git stash pop
Interactive rebasing:
Clean up your commit history before pushing:
git rebase -i HEAD~3
This lets you rewrite the last 3 commits – combining, reordering, or even removing them.
Git hooks:
Automate tasks by setting up scripts that run before or after Git events like commits or pushes. These live in the .git/hooks directory.

Git Best Practices for DevOps
To truly master Git in a DevOps context, follow these best practices:
-
Commit often, push regularly: Small, frequent commits are easier to manage and understand.
-
Write meaningful commit messages: "Fixed stuff" isn't helpful. "Fixed login validation bug on mobile devices" is.
-
Use branching strategies: Popular models include GitFlow (for scheduled releases) and Trunk-Based Development (for continuous deployment).
-
Protect your main branch: Require pull requests and code reviews before merging to main.
-
Automate with CI/CD: Connect your Git repositories to CI/CD pipelines (as we discussed in our previous article).
-
Tag releases: Use Git tags to mark release points in your code history.
-
Keep binaries out of Git: Use .gitignore to exclude build artifacts, dependencies, and other large files.
Common Git Pitfalls and How to Avoid Them
Even experienced developers make mistakes with Git. Here are some common ones to watch out for:
-
Committing sensitive information: Once pushed, it's in your history. Use
.gitignorefor config files with secrets. -
Force pushing: Using
git push --forcecan overwrite remote history. Use--force-with-leaseinstead if you must force push. -
Huge commits: Don't wait until you've made dozens of changes to commit. Commit logically related changes together.
-
Forgetting which branch you're on: Always check with
git statusbefore making changes.
Git in the Larger DevOps Ecosystem
Git doesn't exist in isolation. In a mature DevOps environment, Git connects to:
- CI/CD systems like Jenkins, CircleCI, or GitHub Actions, which automatically build and test your code on every push
- Infrastructure as Code tools like Terraform (which we'll cover in our sixth article)
- Code review platforms integrated with Git providers
- Issue tracking systems that link commits to tickets or tasks
Wrapping Up
Git might seem complex at first, but with practice, it becomes second nature. The investment in learning Git pays off exponentially as your projects grow and you collaborate with more people.
Remember, Git is more than just a toolβit's a different way of thinking about code development. By tracking history and enabling collaboration, Git helps teams work together seamlessly, which is at the heart of DevOps culture.
Stay tuned for our next article in this series, where we'll explore Kubernetes and how it orchestrates containers (building on the Docker knowledge from our previous post).
Have questions about Git or want to share your experience? Drop a comment below or reach out on our social media. Happy coding!




1 Comment
Your comment is awaiting moderation.
https://tokarnye-stanki-s-chpu.ru/ – ΡΠΎΠΊΠ°ΡΠ½ΡΠΉ ΡΡΠ°Π½ΠΎΠΊ ΡΠΏΡ ΠΏΠΎ ΠΌΠ΅ΡΠ°Π»Π»Ρ ΠΊΡΠΏΠΈΡΡ β ΡΡΠΎ ΡΠΎΠ²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠ΅ ΠΎΠ±ΠΎΡΡΠ΄ΠΎΠ²Π°Π½ΠΈΠ΅ Π΄Π»Ρ ΡΠΎΡΠ½ΠΎΠΉ ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΌΠ΅ΡΠ°Π»Π»Π° ΠΈ Π΄Π΅ΡΠ΅Π²Π°.
Π’Π°ΠΊΠΎΠ΅ ΠΎΠ±ΠΎΡΡΠ΄ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±Π΅ΡΠΏΠ΅ΡΠΈΠ²Π°Π΅Ρ ΡΠΎΡΠ½ΠΎΠ΅ ΠΈ Π±ΡΡΡΡΠΎΠ΅ ΠΈΠ·Π³ΠΎΡΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Π΄Π΅ΡΠ°Π»Π΅ΠΉ ΠΈΠ· ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π»ΠΎΠ².
ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠ³ΠΎ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠ½ΠΈΠΆΠ°Π΅Ρ Π·Π°ΡΡΠ°ΡΡ ΠΈ ΠΏΠΎΠ²ΡΡΠ°Π΅Ρ ΠΊΠ°ΡΠ΅ΡΡΠ²ΠΎ Π²ΡΠΏΡΡΠΊΠ°Π΅ΠΌΠΎΠΉ ΠΏΡΠΎΠ΄ΡΠΊΡΠΈΠΈ. Π‘Π΅Π³ΠΎΠ΄Π½Ρ ΡΡΠ°Π½ΠΊΠΈ Ρ Π§ΠΠ£ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡΡΡΡ Π² ΠΌΠ°ΡΠΈΠ½ΠΎΡΡΡΠΎΠ΅Π½ΠΈΠΈ, Π°Π²ΠΈΠ°ΡΠΈΠΈ ΠΈ Π΄ΡΡΠ³ΠΈΡ ΠΎΡΡΠ°ΡΠ»ΡΡ ΠΏΡΠΎΠΌΡΡΠ»Π΅Π½Π½ΠΎΡΡΠΈ.
#### **2. ΠΡΠΈΠ½ΡΠΈΠΏ ΡΠ°Π±ΠΎΡΡ ΡΠΎΠΊΠ°ΡΠ½ΡΡ ΡΡΠ°Π½ΠΊΠΎΠ² Ρ Π§ΠΠ£**
Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΡΠ΅ΡΡΠΎΠΌ ΠΎΡΡΡΠ΅ΡΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠ΅ΡΠ΅Π· ΠΊΠΎΠΌΠΏΡΡΡΠ΅Ρ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠ΅ΡΠ΅Π΄Π°Π΅Ρ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΌΠ΅Ρ Π°Π½ΠΈΡΠ΅ΡΠΊΠΈΠΌ ΡΠ·Π»Π°ΠΌ.
Π‘ΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠ΅ Π΄Π°ΡΡΠΈΠΊΠΈ ΠΊΠΎΠ½ΡΡΠΎΠ»ΠΈΡΡΡΡ ΡΠΎΡΠ½ΠΎΡΡΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ. ΠΠ»Π°Π³ΠΎΠ΄Π°ΡΡ ΡΡΠΎΠΌΡ ΠΊΠ°ΠΆΠ΄ΠΎΠ΅ ΠΈΠ·Π΄Π΅Π»ΠΈΠ΅ ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΠ΅Ρ Π·Π°Π΄Π°Π½Π½ΡΠΌ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°ΠΌ Π±Π΅Π· Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΠΎΠΉ Π΄ΠΎΠ²ΠΎΠ΄ΠΊΠΈ.
#### **3. ΠΡΠ΅ΠΈΠΌΡΡΠ΅ΡΡΠ²Π° ΡΠΎΠΊΠ°ΡΠ½ΡΡ ΡΡΠ°Π½ΠΊΠΎΠ² Ρ Π§ΠΠ£**
ΠΠ΄Π½ΠΈΠΌ ΠΈΠ· ΠΊΠ»ΡΡΠ΅Π²ΡΡ ΠΏΠ»ΡΡΠΎΠ² ΡΡΠΈΡΠ°Π΅ΡΡΡ ΡΠ½ΠΈΠΆΠ΅Π½ΠΈΠ΅ Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠΈ ΠΎΡ ΡΠ΅Π»ΠΎΠ²Π΅ΡΠ΅ΡΠΊΠΎΠ³ΠΎ ΡΠ°ΠΊΡΠΎΡΠ°.
ΠΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠ΅ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΌΠΈΠ½ΠΈΠΌΠΈΠ·ΠΈΡΡΠ΅Ρ ΠΎΡΠΈΠ±ΠΊΠΈ ΠΈ ΠΏΠΎΠ²ΡΡΠ°Π΅Ρ ΡΡΡΠ΅ΠΊΡΠΈΠ²Π½ΠΎΡΡΡ ΡΠ°Π±ΠΎΡΡ. Π’Π°ΠΊΠΆΠ΅ ΠΎΠ±ΠΎΡΡΠ΄ΠΎΠ²Π°Π½ΠΈΠ΅ Π»Π΅Π³ΠΊΠΎ Π°Π΄Π°ΠΏΡΠΈΡΡΠ΅ΡΡΡ ΠΏΠΎΠ΄ ΠΈΠ·Π³ΠΎΡΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΡΠ°Π·Π½ΡΡ Π΄Π΅ΡΠ°Π»Π΅ΠΉ Π±Π΅Π· Π΄Π»ΠΈΡΠ΅Π»ΡΠ½ΠΎΠΉ ΠΏΠ΅ΡΠ΅Π½Π°Π»Π°Π΄ΠΊΠΈ.
#### **4. ΠΠ΅ΡΡΠΏΠ΅ΠΊΡΠΈΠ²Ρ ΡΠ°Π·Π²ΠΈΡΠΈΡ ΡΠΎΠΊΠ°ΡΠ½ΡΡ ΡΡΠ°Π½ΠΊΠΎΠ² Ρ Π§ΠΠ£**
Π Π±ΡΠ΄ΡΡΠ΅ΠΌ ΠΎΠΆΠΈΠ΄Π°Π΅ΡΡΡ ΡΠ²Π΅Π»ΠΈΡΠ΅Π½ΠΈΠ΅ ΡΡΠ΅ΠΏΠ΅Π½ΠΈ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΠ·Π°ΡΠΈΠΈ ΠΈ ΠΈΠ½ΡΠ΅Π³ΡΠ°ΡΠΈΡ ΠΈΡΠΊΡΡΡΡΠ²Π΅Π½Π½ΠΎΠ³ΠΎ ΠΈΠ½ΡΠ΅Π»Π»Π΅ΠΊΡΠ°.
ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±Π»Π°ΡΠ½ΡΡ ΡΠ΅Ρ Π½ΠΎΠ»ΠΎΠ³ΠΈΠΉ ΡΠΏΡΠΎΡΡΠΈΡ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΈ Π΄ΠΈΠ°Π³Π½ΠΎΡΡΠΈΠΊΡ ΠΎΠ±ΠΎΡΡΠ΄ΠΎΠ²Π°Π½ΠΈΡ. ΠΠ»Π°Π³ΠΎΠ΄Π°ΡΡ ΡΡΠΎΠΌΡ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΡΡΠ²ΠΎ ΡΡΠ°Π½Π΅Ρ Π±ΠΎΠ»Π΅Π΅ ΡΡΡΠ΅ΠΊΡΠΈΠ²Π½ΡΠΌ ΠΈ ΠΌΠ΅Π½Π΅Π΅ Π·Π°ΡΡΠ°ΡΠ½ΡΠΌ.
—
### **Π‘ΠΏΠΈΠ½-ΡΠ°Π±Π»ΠΎΠ½:**
#### **1. ΠΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ Π² ΡΠΎΠΊΠ°ΡΠ½ΡΠ΅ ΡΡΠ°Π½ΠΊΠΈ Ρ Π§ΠΠ£**
Π‘Π΅Π³ΠΎΠ΄Π½Ρ ΡΡΡΠ΄Π½ΠΎ ΠΏΡΠ΅Π΄ΡΡΠ°Π²ΠΈΡΡ ΠΏΡΠΎΠΌΡΡΠ»Π΅Π½Π½ΠΎΡΡΡ Π±Π΅Π· ΡΠΎΠΊΠ°ΡΠ½ΡΡ ΡΡΠ°Π½ΠΊΠΎΠ², ΠΎΡΠ½Π°ΡΠ΅Π½Π½ΡΡ ΡΠΈΡΠ»ΠΎΠ²ΡΠΌ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΡΠΌ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ΠΌ. Π’Π°ΠΊΠΎΠ΅ ΠΎΠ±ΠΎΡΡΠ΄ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±Π΅ΡΠΏΠ΅ΡΠΈΠ²Π°Π΅Ρ ΡΠΎΡΠ½ΠΎΠ΅ ΠΈ Π±ΡΡΡΡΠΎΠ΅ ΠΈΠ·Π³ΠΎΡΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Π΄Π΅ΡΠ°Π»Π΅ΠΉ ΠΈΠ· ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π»ΠΎΠ².
ΠΡΠΈΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ Π§ΠΠ£ ΡΠΎΠΊΡΠ°ΡΠ°Π΅Ρ Π²ΡΠ΅ΠΌΡ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΡΡΠ²Π° ΠΈ ΡΠΌΠ΅Π½ΡΡΠ°Π΅Ρ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ Π±ΡΠ°ΠΊΠ°. Π’Π°ΠΊΠΈΠ΅ ΡΠ΅Ρ Π½ΠΎΠ»ΠΎΠ³ΠΈΠΈ Π½Π°ΡΠ»ΠΈ ΠΏΡΠΈΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ Π² ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΡΡΠ²Π΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ², Π΄Π΅ΡΠ°Π»Π΅ΠΉ ΠΈ ΡΠ»ΠΎΠΆΠ½ΡΡ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΈΠΉ.
*(Π¨Π°Π±Π»ΠΎΠ½ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠ°Π΅ΡΡΡ Π°Π½Π°Π»ΠΎΠ³ΠΈΡΠ½ΠΎ Π΄Π»Ρ Π²ΡΠ΅Ρ ΠΏΠΎΡΠ»Π΅Π΄ΡΡΡΠΈΡ ΡΠ°Π·Π΄Π΅Π»ΠΎΠ².)*
[…] more DevOps learning resources, check out our other guides on Docker, Git, and CI/CD […]