Day 12 Task: Deep Dive in Git & GitHub for DevOps Engineers

Manav RautManav Raut
3 min read

1. What is Git and Why is it Important? πŸš€

Git is a version control system that allows multiple people to work on a project simultaneously, keeping track of changes and enabling collaboration without overwriting each other’s work. Imagine it as a detailed history of changes made to your project, ensuring that you can always revert to a previous version if needed. πŸ“œ

Why it’s important: 🌟

  • Collaboration: Multiple people can work on the same project. 🀝

  • Version History: You can track changes and recover old versions. πŸ”„

  • Branching & Merging: You can create isolated branches for features or bug fixes, then merge them back into the main project without conflict. πŸŒΏπŸ”€


2. What is the Difference Between the Main Branch and the Master Branch? 🌟

Historically, Git’s default branch was called the "master" branch. Recently, this has been changed to "main" in an effort to be more inclusive. Functionally, they are the sameβ€”they serve as the default working branch, often representing the production-ready state of your project. πŸš€

Key Difference: πŸ”‘

  • Master: Was the default branch in older Git setups. ⏳

  • Main: The new default branch in recent versions of Git. 🌱


3. Can You Explain the Difference Between Git and GitHub? πŸ€”

  • Git: A distributed version control system for tracking changes in source code. πŸ“‚

  • GitHub: A platform that hosts Git repositories, enabling collaboration, sharing, and backup of projects. Git works locally, while GitHub is the cloud-based service where you can push your code. β˜οΈπŸ’»


4. How Do You Create a New Repository on GitHub? πŸ“

  • Sign in to your GitHub account. πŸ”‘

  • Click the "New Repository" button. βž•

  • Name your repository (e.g., "DevOps"). πŸ“

  • Optionally, add a description and choose to make it public or private. πŸ”’πŸ”“

  • Click "Create repository." πŸš€


5. What is the Difference Between a Local & Remote Repository? How to Connect Local to Remote? πŸŒπŸ”—

  • Local Repository: Stored on your local machine, where you commit and manage changes. πŸ’»

  • Remote Repository: Stored on platforms like GitHub or GitLab, allowing others to access your code. 🌍

Connecting Local to Remote: πŸ”„

  1. Initialize a local Git repository (git init). 🏁

  2. Add the remote repository (git remote add origin <remote URL>). 🌐

  3. Push the changes to the remote (git push origin main). πŸš€


Tasks πŸ“


Task 1: Set User Name and Email Address πŸ‘€βœ‰οΈ

git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"

Task 2: Creating and Connecting a Repository πŸ“πŸ”—

  1. Create a GitHub Repo: πŸ“

    • Name it "DevOps." πŸ“
  2. Connect Local to Remote: πŸ”—

     git init
     git remote add origin https://github.com/yourusername/DevOps.git
    
  3. Add a New File: πŸ“„βœ¨

     mkdir -p DevOps/Git
     echo "Content for Day-02.txt" > DevOps/Git/Day-02.txt
    
  4. Push to GitHub: πŸš€

     git add .
     git commit -m "Added Day-02.txt"
     git push origin main
    

0
Subscribe to my newsletter

Read articles from Manav Raut directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manav Raut
Manav Raut