๐Ÿ“ **Git & GitHub for DevOps Engineers** ๐Ÿš€

ยท

3 min read

Table of contents

No heading

No headings in the article.

Hello fellow DevOps enthusiasts! Today, we are going to take a deep dive into the world of Git and GitHub, two powerful tools that are essential for modern software development and version control. 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 was created by Linus Torvalds in 2005 and has since become the de facto standard for version control in the software development industry.

๐Ÿ“ˆ The importance of Git lies in its ability to enable collaboration among developers working on the same project. It allows multiple developers to work on different features simultaneously, and then seamlessly merge their changes together. Git also provides a history of all changes made to the codebase, which helps in identifying and resolving issues.

๐Ÿƒ Difference Between Main Branch and Master Branch

In Git, "main" and "master" branches are typically used interchangeably. They represent the default branch that contains the latest stable code. In the past, "master" was more commonly used, but in recent years, many organizations have adopted the term "main" to avoid any potentially offensive connotations of the word "master." Functionally, there is no difference between the two.

๐Ÿค Difference between Git and GitHub

Git and GitHub are often confused, but they serve different purposes. Git is the version control system itself, while GitHub is a web-based platform that provides hosting for Git repositories. In simpler terms, Git is like the engine of a car, while GitHub is like the platform where you can park and share your car with others.

๐Ÿ Creating a new repository on GitHub

Let's jump into the tasks and see how we can create a new repository on GitHub and connect it to our local environment!

๐Ÿ”จ Task-1: Setting up your identity

To associate your commits with your name and email address, use the following Git commands in your terminal:

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

โœจ Task-2: Creating the "Devops" repository on GitHub

  1. Log in to your GitHub account and click on the "+" sign at the top right corner.

  2. Select "New repository" from the dropdown menu.

  3. Name your repository as "Devops" and add a brief description if you'd like.

  4. Click on "Create repository" to create the repository.

๐Ÿ”— Connecting local repository to GitHub

Now that we have our repository on GitHub, let's connect it to our local environment.

  1. Open your terminal and navigate to the root folder of your project.

  2. Run the following command to initialize a new Git repository:

git init
  1. Link your local repository to the one on GitHub:
git remote add origin <URL-of-your-GitHub-repository>
  1. ๐ŸŽ‰ Congratulations! Your local repository is now connected to the repository on GitHub.

๐Ÿ“ Creating a new file and pushing changes

Let's complete the final tasks!

  1. Create a new file called "Day-02.txt" in the "Git" folder inside your "Devops" repository.

  2. Add some content to the file using your favorite text editor.

  3. Stage the changes:

git add Git/Day-02.txt
  1. Commit the changes:
git commit -m "Add Day-02.txt with some content"
  1. Push the changes to GitHub:
git push origin main

๐Ÿš€ You did it! Your local changes are now reflected in your GitHub repository.

That's it for today's deep dive into Git and GitHub. We hope you had a great time learning about version control and how to use these tools effectively. Happy coding! ๐ŸŽ‰๐Ÿ’ป

ย