Day 13/90: Advanced Git & GitHub for DevOps Engineers 🌲 #90DaysOfDevOps

kanav_gathe

Kanav Gathe

Posted on October 23, 2024

Day 13/90: Advanced Git & GitHub for DevOps Engineers 🌲 #90DaysOfDevOps

Day 13: Advanced Git Operations 🚀

Hello DevOps enthusiasts! 👋 Welcome to Day 13 of the #90DaysOfDevOps challenge. Today, we're exploring advanced Git operations.

Task Solutions 💻

Task 1: Feature Development with Branches

1. Create Branch and Add Feature

# Create and switch to new branch
git checkout -b dev

# Add initial content
echo "This is the first feature of our application" > Devops/Git/version01.txt
git add .
git commit -m "Added new feature"

# Push to GitHub
git push origin dev
Enter fullscreen mode Exit fullscreen mode

2. Add Multiple Features

# Feature 2
echo "This is the bug fix in development branch" >> Devops/Git/version01.txt
git commit -am "Added feature2 in development branch"

# Feature 3
echo "This is gadbad code" >> Devops/Git/version01.txt
git commit -am "Added feature3 in development branch"

# Feature 4
echo "This feature will gadbad everything from now" >> Devops/Git/version01.txt
git commit -am "Added feature4 in development branch"
Enter fullscreen mode Exit fullscreen mode

3. Revert Changes

# Revert to previous state
git revert HEAD~2
Enter fullscreen mode Exit fullscreen mode

Task 2: Branch Operations

1. Create Multiple Branches

# Create branches
git branch feature1
git branch feature2
Enter fullscreen mode Exit fullscreen mode

2. Merge Changes

# Switch to main and merge
git checkout main
git merge dev
Enter fullscreen mode Exit fullscreen mode

3. Rebase Example

# Rebase feature branch
git checkout feature1
git rebase main
Enter fullscreen mode Exit fullscreen mode

Common Git Operations 🔧

Reset vs Revert

# Reset (changes history)
git reset --hard HEAD~1

# Revert (creates new commit)
git revert HEAD
Enter fullscreen mode Exit fullscreen mode

Merge vs Rebase

# Merge (creates merge commit)
git checkout main
git merge feature

# Rebase (linear history)
git checkout feature
git rebase main
Enter fullscreen mode Exit fullscreen mode

Key Takeaways 💡

  • Branches enable parallel development
  • Revert safely undoes changes
  • Reset modifies history
  • Merge preserves complete history
  • Rebase creates linear history
  • Choose right operation for situation

Git #DevOps #GitHub #BranchingStrategy #90DaysOfDevOps


This is Day 13 of my #90DaysOfDevOps journey. Keep branching and merging!

💖 💪 🙅 🚩
kanav_gathe
Kanav Gathe

Posted on October 23, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related