Installing Git and Writing Your First Command: A Beginner’s Guide

Table of contents
- Installing Git
- Configuring Git
- Writing Your First Git Commands
- Scenario: Tracking a Shell Script with Git
- Step 1: Create a New Project Folder
- Step 2: Initialize a Git Repository (git init)
- What does it do?
- Step 3: Create a New File (deploy.sh)
- Step 4: Check the Status of the Repository (git status)
- What does it do?
- Step 5: Add the File to Staging (git add)
- What does it do?
- Step 6: Commit the Changes (git commit)
- What does it do?
- Final Step: Check Repository Status (git status)
- Summary of the Workflow

Hey hey, fellas! Now that you’ve got a solid understanding of Git, let’s not waste any time and jump straight into installing Git on your system!
But wait—what’s learning without a little hands-on action? We’ll not only get Git up and running but also run some essential Git commands to get you comfortable with it.
I hope you're excited! Let’s dive in and get started!
Installing Git
Why Install Git Locally?
Offline Work: Track changes without needing a remote repository (GitHub/GitLab).
Practice Fundamentals: Learn Git commands before integrating with platforms like GitHub.
Installation Steps
1️⃣ Installing Git on Linux
🔹 Open the terminal and install Git based on your Linux distribution:
For Debian-based (Ubuntu, Kali, etc.):
sudo apt update && sudo apt install git -y
For RHEL-based (CentOS, Fedora, Amazon Linux, etc.):
sudo yum install git -y # or dnf install git -y
For Arch Linux:
sudo pacman -S git
2️⃣ Installing Git on Windows
🔹 Download the latest Git version from the official site: Git for Windows
🔹 Run the installer, follow the prompts, and choose default settings.
3️⃣ Installing Git on macOS
🔹 Install Git using Homebrew (Recommended):
brew install git
🔹 Or install Xcode Command Line Tools (if Homebrew is not available):
xcode-select --install
4️⃣ Verifying Installation
Run the following command to check if Git is installed:
git --version
DevOps Use Cases for Installation
Local Script Management:
- Track changes to infrastructure-as-code (e.g., Ansible playbooks).
Documentation Versioning:
- Maintain version history for runbooks or deployment guides.
Configuring Git
Why Configure Git?
Before using Git, every commit needs an identity (username & email) to track who made changes.
Git Configuration Levels:
Config Level | Scope | Command Example |
System | Applies to all users | git config --system user.name "Raj" |
Global | Applies to current user | git config --global user.name "Raj" |
Local | Applies only to specific repo | git config --local user.name "Raj" |
Setting Username and Email
Run these global commands (affects all repositories):
git config --global user.name "Rajratan Gaikwad"
git config --global user.email "rajratangaikwad26@gmail.com"
✅ Verify configuration:
git config --global --list
🔹 You don’t need GitHub or any repository for this step. These settings are stored locally on your system.
DevOps Use Cases for Configuration
Work vs. Personal Projects:
- Use different emails for company projects (
work@company.com
) and personal scripts (dev@example.com
).
- Use different emails for company projects (
Team Collaboration:
- Ensure everyone on the team uses consistent naming (e.g.,
FirstName LastName
).
- Ensure everyone on the team uses consistent naming (e.g.,
Writing Your First Git Commands
Scenario: Tracking a Shell Script with Git
Imagine you're a DevOps Engineer who wants to track a simple shell script (deploy.sh
) that automates server deployment.
Step 1: Create a New Project Folder
mkdir Git_GitHub && cd Git_GitHub
Step 2: Initialize a Git Repository (git init
)
What does it do?
🔹 Creates a hidden .git
folder that tracks changes.
🔹 This does not push to GitHub, it’s purely local.
git init
✅ Output:
Initialized empty Git repository in /home/raga/DevOps/Git_GitHub/.git/
Change branch from master to main:
Step 3: Create a New File (deploy.sh
)
echo '#!/bin/bash' > deploy.sh
echo 'echo "Deploying Application..."' >> deploy.sh
✅ Check Files in Directory
ls
✅ Output:
deploy.sh
Step 4: Check the Status of the Repository (git status
)
What does it do?
🔹 Shows the current state of files in the repo.
git status
✅ Output:
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
deploy.sh
🔹 Git tells us that deploy.sh
is untracked.
Step 5: Add the File to Staging (git add
)
What does it do?
Moves files to the staging area before committing.
git add deploy.sh
✅ Check Status Again
git status
✅ Output:
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: deploy.sh
🔹 Now, deploy.sh
is in the staging area.
Step 6: Commit the Changes (git commit
)
What does it do?
Creates a snapshot of the staged changes.
git commit -m "Add deployment script"
✅ Output:
[main (root-commit) 1213650] Add deployment script
1 file changed, 2 insertions(+)
create mode 100644 deploy.sh
🔹 Now, deploy.sh
is saved in Git history.
Final Step: Check Repository Status (git status
)
git status
✅ Output:
On branch main
nothing to commit, working tree clean
🔹 This means everything is committed, and no changes are pending.
Summary of the Workflow
Step | Command | Purpose |
Initialize | git init | Start version control in a folder |
Check Status | git status | See untracked/modified files |
Add to Staging | git add deploy.sh | Prepare file for commit |
Commit | git commit -m "Add deployment script" | Save changes permanently |
Now, this project is tracked in Git, and you can make further changes while keeping history.
Cheers to us! We’ve successfully installed Git, configured it, and even run our first Git commands—how awesome is that?
How does it feel now? Pretty great, right? Well, you should be proud! But hey, it’s not over yet—we’ve only scratched the surface. Next up we will Modify deploy.sh
add changes and commit again and mainly we will learn about branching and merging before pushing to GitHub.
Stay pumped, because things are about to get even more exciting!
Until next time, keep coding, automating, and advancing in DevOps! 😁
Peace out ✌️
Subscribe to my newsletter
Read articles from Rajratan Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Rajratan Gaikwad
Rajratan Gaikwad
I write about the art and adventure of DevOps, making complex topics in CI/CD, Cloud Automation, Infrastructure as Code, and Monitoring approachable and fun. Join me on my DevOps Voyage, where each post unpacks real-world challenges, explores best practices, and dives deep into the world of modern DevOps—one journey at a time!