Deep Dive in Git & GitHub for DevOps Engineers

Deep Dive in Git & GitHub for DevOps Engineers

#90DaysOfDevOps

What is Git and why it is important?

Git is a DevOps tool for managing source code. It is a version control system that can efficiently manage small to very large projects and is free and open-source. Git is a tool used to log source code changes, allowing several engineers to collaborate on non-linear development. Git was developed in 2005 by Linus Torvalds for Linux kernel development.

Importance of Git:- GIT, as a useful distributed version control system tool, helps the communication between the operation team and the development easier. Communication in Version Control is critical to succeeding in DevOps, and therefore GIT tool plays an active role in succeeding in DevOps.

What is the difference between the main branch and the master branch?

The Main or Master branch is the default branch. GitHub uses the main branch as its default branch while others use the master branch as their default branch.

Can you explain the difference between Git and Github?

Git:- Git is a type of software. It is a distributed type of version control system that tracks the changes occurring in the source code during the process of software development. It is a command-line tool. Linux maintains Git. One needs to install Git on their system/ device locally. The primary focus of Git is code sharing and version control. It was released back in the year 2005. It comes with no feature for user management.

GitHub:- GitHub is a type of service. It is a hosting service for the Git repository that is web-based. It is a Graphical UI (User Interface). Microsoft maintains GitHub. The web hosts GitHub. You don’t have to install it. The primary focus of GitHub is the hosting of the centralized source code. It was released back in the year 2008. It comes with a built-in feature for user management.

How do you create a new repository on GitHub?

There is a plus icon (+) on github.com for creating a new repository. You can see in the below image. Click on the plus icon and then click on the new repository to create a new repository.

  • After clicking on the new repository, enter the repository name and add a brief description of it.

  • Make the repo private/public according to your requirement.

  • Now click on create a repository to create newly repo.

What is the difference between local & remote repositories? How to connect local to remote?

Local repositories reside on the computers of team members. In contrast, remote repositories are hosted on a server that is accessible to all team members - most likely on the internet or a local network.

Connect locally to the remote repository:-

git remote add origin <remote repo url>

git push --all origin

If you want to set all of your branches to automatically use this remote repository when you use git pull, add --set-upstream to the push:

git push --all --set-upstream origin

Task (1):-

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

Task (2):-

Create a repository named "DevOps" on GitHub.

Connect your local repository to the repository on GitHub.

Create a new file in the DevOps folder named file1.txt and add some content to it.

Push your local commits to the repository on GitHub