Skip to main content

Command Palette

Search for a command to run...

Day 9 - Deep Dive in Git & GitHub for DevOps Engineers (Dec 5, 2023)

Updated
3 min read
Day 9 - Deep Dive in Git & GitHub for DevOps Engineers (Dec 5, 2023)

Introduction to Git and Its Significance

Git is a distributed version control system that allows developers to track changes in their code, collaborate with others, and manage project history effectively. Developed by Linus Torvalds, the creator of Linux, Git has become a fundamental tool for software development.

Why is Git Important?

  1. Version Control: Git enables developers to track changes, compare versions, and revert to previous states easily. This promotes collaboration and ensures code stability.

  2. Collaboration: Git facilitates collaboration among team members by providing a centralized platform for code storage and sharing. Multiple developers can work on the same project simultaneously without conflicts.

  3. Branching and Merging: Branching allows developers to work on features or fixes independently, and merging integrates these changes seamlessly. This enables parallel development without affecting the main codebase.

  4. History and Accountability: Git maintains a detailed history of changes, including who made them and when. This accountability is crucial for debugging and auditing purposes.

Main Branch vs. Master Branch

Historically, Git repositories used the term "master" to refer to the default branch. However, to promote inclusive language, many projects have transitioned to using "main" instead of "master."

Difference Between Main Branch and Master Branch

In essence, the only difference is the naming convention. "Main" and "master" are used interchangeably to denote the primary branch in a Git repository. It's a symbolic change with no impact on Git's functionality.

Git vs. GitHub: Understanding the Distinction

While Git and GitHub are often used together, they serve distinct purposes.

Git

Git is the version control system itself, providing the framework for managing and tracking changes in source code. It operates locally on a developer's machine, allowing them to work offline and commit changes to their local repository.

GitHub

GitHub, on the other hand, is a web-based platform that hosts Git repositories. It adds a collaborative layer by allowing multiple developers to work on the same project, providing features like issue tracking, pull requests, and a visual interface to manage repositories.

Setting Up and Creating a Repository

Now, let's delve into the practical aspects of Git and GitHub with the provided tasks.

Task-1: Set User Name and Email Address

Before making any commits, it's essential to set up your identity using the following commands:

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

Task-2: Create and Connect to a GitHub Repository

  1. Create a Repository:

    • Go to GitHub.

    • Click on the "+" sign in the upper right corner and select "New repository."

    • Name it "Devops" and provide a brief description.

    • Click "Create repository."

  2. Connect Local Repository to GitHub:

    • Navigate to your local repository's root folder in the terminal.

    • Execute the following commands:

        git remote add origin https://github.com/your-username/Devops.git
        git branch -M main
        git push -u origin main
      

Task-3: Create a New File and Push to GitHub

  1. Create a New File:

    • Inside your local repository, create the file "Devops/Git/Day-02.txt."

    • Add some content to the file.

  2. Push to GitHub:

    • Use the following commands:

        git add .
        git commit -m "Add Day-02.txt with content"
        git push origin main
      

More from this blog

DevOps Journey with M Hassan

174 posts

I am writing these blogs because I recently completed a comprehensive DevOps course where I gained in-depth knowledge of the topics mentioned. As I progressed through the course, I realized the importance of having a concise and accessible resource to revise and reinforce my understanding of each topic. Therefore, I decided to create cheat sheets in the form of blog posts. These cheat sheets will not only serve as a handy reference for myself but also benefit others who are also interested in mastering DevOps concepts. By documenting each topic and providing concise explanations, I aim to create a valuable resource that simplifies complex concepts and facilitates hands-on practice. This way, I can solidify my own understanding while helping others on their DevOps journey.