#9 :  Deep Dive in Git & GitHub for DevOps Engineers Part-2.

#9 : Deep Dive in Git & GitHub for DevOps Engineers Part-2.

Introduction

Hello Friends, How are you? I am Parimal Pradhan, Today we are going deep dive into Git & GitHub. I tried to explain the basics of Git and GitHub in the last blog. As a DevOps engineer, you should know the below task:

  • Creating Repository

  • Creating Branches (DEV, QA, UAT, PROD) etc., as per the project requirement.

  • Providing access to respective branches.

  • Secure Prod and UAT branches.

What is Git and why is it important?

Git is a distributed version control system tool that is used to keep track of our projects or files. It is installed on the local machine i.e on a developer machine.

with the help of the git init command, we can create local repo.

Now why it is important?

  • To keep track of the file changes i.e. who made changes, when it is made and can revert.

  • It makes collaboration easier. people work together on the same project.

  • It has distributed architecture so each developer has a copy of a central repository. so if something happens to the central repository then we have a copy of it on the local machine.

What is the difference Between Main Branch and Master Branch??

There is no difference between both branch names.

Previously default branch name of the repository was Master but now when you create a new repository on GitHub the default branch is Main.

Can you explain the difference between Git and GitHub?

How do you create a new repository on GitHub?

Now as a DevOps engineer, you must know how to create a new repository on GitHub.Just follow the below steps:

  1. Go to GitHub account https://github.com/

  2. Click on the + sign right-hand corner upper side. For more understanding see the below image.

  3. Now we will create a new repository and the repository name would be DevOps.

    add a description and click on create repository button.

    What is the difference between local & remote repositories?

Local repositories are always on the local machine. after installation of git on the local machine you can create a local repository by using the git init command. when you use git init hidden folder is created on the local machine folder would be like .git.

Other developers can't access local repositories.

Central repositories are hosted on the web so everyone can access them if it is public. All the project source code is kept in central repositories so the developer can access it and make changes accordingly.

How to connect local to remote repository?

As we have created a local repository and a central repository. Now we have to make the connection between them. so for the first time, we have to run the below command on the local machine.

git remote add origin <remote_repo_URL>

How to check whether the local repository is connected or not?

use the git remote -v command on the local machine.

Tasks

Set your user name and email address, which will be associated with your commits.

git config — global user.name “parimal”

git config — global user.email

connect local to remote repository with the below command

git remote add origin <remote_repo_URL>

Create a new file in Devops/Git/Day-02.txt & add some content to it

Push your local commits to the repository on GitHub

Thank You for reading this blog

Parimal Pradhan

You can follow me on LinkedIn for my daily updates:- linkedin.com/in/parimal-pradhan-b62021168

Great initiative by the #trainwithshubham community. Thank you Shubham Londhe

Did you find this article valuable?

Support Parimal Pradhan by becoming a sponsor. Any amount is appreciated!