Day 22 & Day 23 of #90DaysOfDevOps – Getting Started with Git, Branching, and GitHub

Introduction
Over the last few weeks, I've been learning Linux, Shell Scripting, Automation, Cron Jobs, and Bash Projects. Today I started one of the most important tools in the DevOps ecosystem: Git.
Whether you're deploying applications, managing infrastructure as code, contributing to open source projects, or working in a team, Git is everywhere. Every modern DevOps workflow relies on version control.
Over these two days, I learned:
Git fundamentals
Repository creation
Staging and committing changes
Git history
Branching
Working with GitHub
Clone vs Fork
Pulling changes from remote repositories
Why Git Matters
Before Git, tracking changes in projects was difficult. Developers often created multiple copies of files such as:
project-final
project-final-v2
project-final-final
project-final-latest
This quickly became messy.
Git solves this by tracking every change and allowing developers to move back and forth between versions whenever needed.
Installing and Configuring Git
The first step was verifying Git installation and configuring my identity.
git --version
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Verify configuration:
git config --list
This information gets attached to every commit I create.
Creating My First Repository
I created a new directory for practice:
mkdir devops-git-practice
cd devops-git-practice
Initialized Git:
git init
Output:
Initialized empty Git repository
This command created a hidden .git directory.
Exploring the .git Directory
I explored the internal structure:
ls -la
cd .git
ls
Some important files:
HEAD
config
objects
refs
hooks
The .git folder contains all repository metadata, commit history, branches, and configuration.
Without this folder, Git stops tracking the project.
Understanding Git Workflow
One of the most important concepts I learned was the Git workflow.
Working Directory
↓
git add
↓
Staging Area
↓
git commit
↓
Repository
Working Directory
Where I create and edit files.
Staging Area
A temporary area where selected changes are prepared for commit.
Repository
The permanent history of commits stored by Git.
Creating My First Commit
I created a Git reference file:
touch git-commands.md
Checked status:
git status
Added the file:
git add git-commands.md
Committed:
git commit -m "Add git commands reference"
My first commit was now saved in Git history.
Building Commit History
I continued updating the file and making commits.
git commit -m "Add setup commands"
git commit -m "Add workflow commands"
git commit -m "Add viewing commands"
Viewing history:
git log --oneline
Example:
ab12345 Add viewing commands
cd67890 Add workflow commands
ef12345 Add setup commands
gh56789 Add git commands reference
This showed how Git stores project history as a sequence of commits.
Understanding Branches
A branch is an independent line of development.
Instead of making every change directly on main, developers create branches for features and fixes.
Benefits:
Safe experimentation
Isolated development
Easier collaboration
Cleaner workflows
Creating Branches
View branches:
git branch
Create a branch:
git branch feature-1
Switch:
git switch feature-1
Create and switch in one command:
git switch -c feature-2
Git Switch vs Checkout
Older method:
git checkout feature-1
Modern method:
git switch feature-1
git switch focuses only on branch operations, making it simpler and safer.
Branch Isolation
On feature-1, I created a new file and committed it.
echo "Feature Work" > feature.txt
git add .
git commit -m "Add feature file"
When I switched back:
git switch main
The file no longer appeared.
This demonstrated how branches maintain separate histories.
Understanding HEAD
HEAD points to the currently checked-out branch or commit.
Example:
HEAD -> main
When switching branches:
HEAD -> feature-1
Git moves the HEAD pointer automatically.
Connecting to GitHub
I created a new repository on GitHub and connected it to my local repository.
git remote add origin https://github.com/username/devops-git-practice.git
Verify:
git remote -v
Pushing to GitHub
Push main branch:
git push -u origin main
Push feature branch:
git push -u origin feature-1
Now both branches were visible on GitHub.
Origin vs Upstream
Origin
The repository I cloned or own.
Example:
my fork
Upstream
The original repository from which the fork was created.
Example:
official project repository
Pulling Changes from GitHub
I edited a file directly on GitHub.
Then updated my local repository:
git pull origin main
This downloaded and merged changes.
Fetch vs Pull
Fetch
git fetch
Downloads changes only.
Pull
git pull
Downloads and merges changes.
Clone vs Fork
Clone
Creates a local copy.
git clone https://github.com/user/repo.git
Fork
Creates a copy of someone else's repository under my GitHub account.
Useful when contributing to open source projects.
Keeping a Fork Updated
Typical workflow:
git remote add upstream https://github.com/original/repo.git
git fetch upstream
git merge upstream/main
This keeps my fork synchronized with the original project.
Commands Learned
Repository Commands
git init
git status
git add
git commit
git log
Branch Commands
git branch
git switch
git switch -c
git checkout
Remote Commands
git remote -v
git push
git pull
git fetch
git clone
What I Learned
1. Git Tracks History Efficiently
Every commit creates a checkpoint that can be revisited later.
2. Branches Enable Safe Development
Branches allow experimentation without affecting the main project.
3. GitHub Makes Collaboration Easier
Pushing repositories and branches to GitHub allows teams to work together efficiently.
Key Takeaways
Created my first Git repository.
Learned the complete Git workflow.
Built commit history with multiple commits.
Understood branches and branch isolation.
Connected local repositories to GitHub.
Pushed and pulled changes.
Learned the difference between clone and fork.
Started building a personal Git command reference.
Git is one of the most important tools in DevOps, and these two days provided a strong foundation for the advanced Git workflows I'll learn next.
Day 22 & Day 23 completed.




