๐ Day 9 Task: Deep Dive in Git & GitHub for DevOps Engineers ๐
Table of contents
No headings in the article.
Hey DevOps Engineers! Today, we're diving deep into the world of Git and GitHub ๐ to understand their importance and how they play a crucial role in modern software development. ๐ฅ๏ธ Let's get started! ๐
๐ค What is Git and why is it important?
Git is a distributed version control system that allows developers to track changes in their code over time. ๐ป It provides a collaborative environment where multiple developers can work on the same project simultaneously without conflicts. Git's importance lies in its ability to:
๐ธ Keep track of code history: Git records every change made to the codebase, enabling easy navigation between different versions. This helps in identifying and fixing bugs efficiently. ๐
๐ธ Facilitate collaboration: Git enables seamless collaboration among developers by allowing them to work on separate branches and then merge their changes together. ๐ฅ
๐ธ Backup and restore: With Git, developers can rest assured that their code is backed up and can be easily restored in case of any data loss. ๐พ
๐ธ Experimentation: Git provides a safe environment for developers to experiment with new features or ideas without affecting the main codebase.
๐ค Difference Between Main Branch and Master Branch
In Git, the main branch is now commonly used as the default branch instead of the traditional "master" branch. Both branches serve similar purposes, but the shift to the "main" branch comes from the desire to avoid any potentially insensitive terminology.
๐ธ Main Branch: The "main" branch in Git is the default branch where the latest stable code is found. It is the primary branch of development and represents the most up-to-date version of the project. ๐ฑ
๐ธ Master Branch: The "master" branch is the older terminology for the default branch. In Git, the "master" branch served the same purpose as the "main" branch, but it is now being phased out. ๐ซ
๐ค Difference Between Git and GitHub
While Git and GitHub are often used interchangeably, they serve different roles in the development process.
๐ธ Git: As mentioned earlier, Git is a version control system that runs locally on your machine. It helps you manage code changes, create branches, and collaborate with other developers. ๐ฅ
๐ธ GitHub: GitHub, on the other hand, is a web-based hosting service for Git repositories. It acts as a remote repository where you can store your code, collaborate with teammates, and leverage various features like issue tracking, pull requests, and more. ๐
๐ How to create a new repository on GitHub?
Creating a new repository on GitHub is a simple process:
Log in to your GitHub account. ๐ฅ๏ธ
Click on the "+ New" button on the top right corner of the screen. ๐
Name your repository "Devops" and add an optional description. ๐
Choose whether you want the repository to be public or private. ๐
Click on "Create repository" to create your new repository. ๐
๐ Difference between local & remote repository and how to connect them
๐ธ Local Repository: A local repository exists on your local machine, where you do your development work. It contains the entire version history of the project. ๐จโ๐ป
๐ธ Remote Repository: A remote repository is hosted on a remote server, like GitHub. It serves as a central hub where multiple developers can collaborate and share their changes. ๐ป
To connect your local repository to the remote repository on GitHub, follow these steps:
Task-1: Set your username and email
Open your terminal and run the following commands, replacing "YourName" and "youremail@example.com" with your GitHub username and email:
git config --global user.name "YourName"
git config --global user.email "youremail@example.com"
Task-2: Create a repository named "Devops" on GitHub
Follow the steps mentioned above to create a new repository named "Devops" on GitHub.
Task-3: Connect your local repository to the remote repository
Navigate to your local repository using the terminal.
Run the following command to add the remote repository URL:
git remote add origin <remote_repository_url>
- Now, your local repository is connected to the remote repository on GitHub.
Task-4: Create a new file in Devops/Git/Day-02.txt & add some content to it
Create a new file named "Day-02.txt" inside the "Git" folder in your local repository. Add some content to the file to represent your progress on Day 2 of the DevOps tasks.
Task-5: Push your local commits to the repository on GitHub
Use the following commands to push your local changes to the remote repository:
git add .
git commit -m "Added Day-02.txt"
git push origin main
๐ Congratulations! You have successfully completed the tasks for Day 9 of the DevOps journey. Keep up the great work! ๐
Remember, Git and GitHub are powerful tools that will greatly enhance your development workflow. Happy coding! ๐๐