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

Naushad KhanNaushad Khan
3 min read

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 🌐

  1. Go to GitHub and create a new repository named "DevOps".

  2. Do not initialize it with a README or .gitignore file.

Task 3: Connecting Local Repository to GitHub πŸ”„

  1. 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
    
  2. 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 πŸ“„βœοΈ

  1. 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
    
  2. 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 πŸš€

  1. 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

2
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! πŸŒβš™οΈ