Day 8 : Basic Git & GitHub for DevOps Engineers.

Day 8 : Basic Git & GitHub for DevOps Engineers.

Git and GitHub are two closely related technologies that have revolutionized the way software development is done. In this blog, we'll take a closer look at what Git and GitHub are, what they do, and how they work together.

What is Git?

Git is a version control system that allows developers to keep track of changes to their code over time. With Git, developers can make changes to their code, save those changes, and then revert to previous versions if needed.

This is incredibly useful when multiple people are working on the same codebase, as it allows developers to collaborate without overwriting each other's changes.

What is GitHub?

GitHub is a web-based platform that allows developers to host their Git repositories online. With GitHub, developers can collaborate on code, share their work with others, and contribute to open-source projects.

GitHub offers a wide range of features, including pull requests, code reviews, issue tracking, and more. These features make it easy for developers to collaborate on code and ensure that everyone is on the same page.

What is Version Control?

Version control is a system that allows developers to manage changes to their code over time. It is an essential tool for software development, as it allows multiple developers to work on the same codebase without interfering with each other's work. Version control systems keep track of changes to code, who made the changes, and when they were made.

There are two main types of version control systems: centralized and distributed.

Centralized Version Control: A centralized version control system (CVCS) uses a central repository to store the codebase and manage changes. Developers check out files from the central repository, make changes, and then check the files back in. Examples of CVCS include Subversion and CVS.

Distributed Version Control: A distributed version control system (DVCS) uses a distributed model, where each developer has their own copy of the codebase and can make changes independently. Changes can then be merged back into the main codebase as needed. Examples of DVCS include Git and Mercurial.

Why do we use distributed version control over centralized version control?

  1. Better collaboration: In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don't have to constantly communicate with a central server to commit their changes or to see the changes made by others.

  2. Improved speed: Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don't have to communicate with a central server.

  3. Greater flexibility: With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.

  4. Enhanced security: In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to data loss. If the central server in a CVCS goes down or the repository becomes corrupted, it can be difficult to recover the lost data.

Overall, the decentralized nature of a DVCS allows for greater collaboration, flexibility, and security, making it a popular choice for many teams.

How to install git?

  • Use the following command to update your system:

      sudo yum update
    
  • Use the following command to install Git:

      sudo yum install git
    

  • After Git has been installed, you can check the version of Git that was installed using the following command:

      git --version
    

Exercises:

  1. Create a new repository on GitHub and clone it to your local machine.

    -> Got to https://github.com/

    -> Give the name to the repository and click on create repository.

  2. Make some changes to a file in the repository and commit them to the repository using Git.

  3. Push the changes back to the repository on GitHub.

Thank you for reading! Hope you find this article helpful.

~Kunal