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?
Version Control: Git enables developers to track changes, compare versions, and revert to previous states easily. This promotes collaboration and ensures code stability.
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.
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.
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
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."

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
Create a New File:
Inside your local repository, create the file "Devops/Git/Day-02.txt."
Add some content to the file.
Push to GitHub:
Use the following commands:
git add . git commit -m "Add Day-02.txt with content" git push origin main




