Day 12 Task: Deep Dive in Git & GitHub for DevOps Engineers
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: π
Initialize a local Git repository (
git init
). πAdd the remote repository (
git remote add origin <remote URL>
). π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 ππ
Create a GitHub Repo: π
- Name it "DevOps." π
Connect Local to Remote: π
git init git remote add origin https://github.com/yourusername/DevOps.git
Add a New File: πβ¨
mkdir -p DevOps/Git echo "Content for Day-02.txt" > DevOps/Git/Day-02.txt
Push to GitHub: π
git add . git commit -m "Added Day-02.txt" git push origin main
Subscribe to my newsletter
Read articles from Manav Raut directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by