Day 12: Deep Dive into Git & GitHub for DevOps Engineers


Let's explore Git & GitHub step by step, understand the concepts, and learn how to perform common tasks with command-line instructions.
Step 1: What is Git and Why is it Important? π€
Git is a distributed version control system that tracks changes in code, enabling multiple developers to collaborate efficiently. It lets you revert changes, create branches, and merge code, making it a key tool for DevOps and software development.
Step 2: Main Branch vs. Master Branch πΏ
Main Branch: A newer default branch name.
Master Branch: The old default name. Both serve as the primary branch where code is merged.
Step 3: Git vs. GitHub π»π
Git: A tool that helps manage your code changes locally.
GitHub: A cloud-based platform that hosts Git repositories, enabling collaboration and remote storage.
Step 4: Local vs. Remote Repository ππ₯οΈ
Local Repository: Stored on your local machine.
Remote Repository: Stored on GitHub or another server. Used for sharing and collaboration.
Step 5: Getting Started β Command Line Guide π§βπ»
Task 1: Setting Up Git Username and Email
bashCopy code# Set your user name
git config --global user.name "Your Name"
# Set your email address
git config --global user.email "your.email@example.com"
Task 2: Create a New Repository on GitHub π
Go to GitHub and create a new repository named "DevOps".
Do not initialize it with a README or .gitignore file.
Task 3: Connecting Local Repository to GitHub π
Create a Local Repository:
bashCopy code# Create a new directory mkdir DevOps # Move into the directory cd DevOps # Initialize a new Git repository git init
Connect Local Repository to Remote:
bashCopy code# Add the remote repository URL git remote add origin https://github.com/your-username/DevOps.git
Task 4: Create a File and Add Content πβοΈ
Create a Directory and File:
bashCopy code# Create a nested directory mkdir -p Git # Navigate to the directory cd Git # Create a new file with content echo "Learning Git and GitHub" > Day-02.txt
Stage and Commit the Changes:
bashCopy code# Add the new file to staging git add Day-02.txt # Commit the changes git commit -m "Added Day-02.txt with content"
Task 5: Push Changes to GitHub π
Push the Local Changes to the Remote Repository:
bashCopy code# Push changes to the remote repository's main branch git push -u origin main
Now, your changes should be reflected in the "DevOps" repository on GitHub!
Creative Ideas to Enhance Your Learning β¨
Draw Diagrams: Use hand-drawn diagrams to visualize concepts like branching, merging, and repository structure.
Write a Blog: Share your Git and GitHub learning experience, and include your hand-drawn diagrams for better explanation.
Collaborate: Invite a friend to contribute to your repository and practice collaborating with GitHub.
Happy coding! Keep learning and growing your DevOps skills. ππ¨βπ»
#DevOps #Git #GitHub #VersionControl #LearningJourney #Automation #Coding #Scripting #90DaysOfDevOps
Subscribe to my newsletter
Read articles from Naushad Khan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Naushad Khan
Naushad Khan
DevOps engineer with a passion for automation, CI/CD, and cloud platforms like AWS. I bridge dev and ops, optimizing workflows and sharing insights through technical blogs. Letβs automate the future! πβοΈ