If you're learning DevOps or tackling hands-on tasks , you will need to know how to install Git and set up a repository on a Linux server. Here's how to do it without the fluff.
This guide walks you through a real-world task: installing Git using yum
and initializing a non-bare repository inside /opt/media.git
.
🛠 Step 1: Install Git Using YUM
First, connect to your Linux server. This could be a VM, cloud instance, or lab environment.
Now, install Git using the yum
package manager:
sudo yum install git -y
The -y
flag automatically confirms the install prompt, so the process runs without interruption.
Once installed, confirm the version:
git --version
If you see a version like git version 2.x.x, you're good to go.
📁 Step 2: Create a Non-Bare Git Repository
Now you need to initialize a Git repository at /opt/media.git
. But careful—this should not be a bare repository.
Here’s how you do it:
sudo mkdir /opt/media.git
cd /opt/media.git
git init
✅ What Just Happened?
mkdir
creates the target directory.
cd
moves into it.
git init
sets up a standard Git repository (with a working directory).
You did not use git init --bare
—because a non-bare repo is what you need here. Non-bare repos are what you use for active development: you can see, edit, and commit files.
🔄 Summary
You just completed a foundational DevOps task:
Installed Git using yum
Created a directory for your repo
Initialized it using git init
(non-bare)
You're now ready to start tracking files, committing changes, and building something real.
To confirm it worked, run:
ls -a
You should see a .git
folder—that’s your repository metadata.
🚀 What's Next?
If you're doing DevOps tasks or preparing for interviews, you'll likely need to:
Clone remote repos
Push changes
Work with git branch and git log
Stick around. More real-world Git and DevOps walkthroughs coming soon.
✍️ Written by Anusha Kuppili
🎥 Also on YouTube: Data Enthusiast Era
Top comments (0)