Day 8 Task: Basic Git & GitHub for DevOps Engineers.

Day 8 Task: Basic Git & GitHub for DevOps Engineers.

What is Git?

Git allows developers to track changes to their code, collaborate with others on a project, and easily revert to previous versions of their code if necessary. It works by creating a repository to store all versions of the code, and then allowing developers to make changes to that code and commit those changes to the repository.

Git also allows developers to create and merge branches, which allows them to work on different versions of the code simultaneously and then merge those changes back into the main branch when they are ready.

Overall, Git is a powerful and flexible tool that is essential for modern software development and collaboration.


What is GitHub?

GitHub is a web-based platform for version control and collaborative software development. It allows developers to store and manage their code, track changes to it over time, and collaborate with other developers on projects. GitHub provides features such as issue tracking, pull requests, code reviews, and project management tools, making it a popular choice for open-source software development and other collaborative programming projects.


Difference between Git and GitHub?

Git is a distributed version control system that allows developers to manage changes to their code over time. It enables developers to track changes to their code, collaborate with others, and revert to previous versions if needed. Git is a command-line tool that can be used locally on a developer's computer or on a remote server.

GitHub, on the other hand, is a web-based platform that provides hosting for Git repositories. It offers additional features such as a graphical user interface, issue tracking, pull requests, and project management tools. GitHub allows developers to share their code with others and collaborate on projects more easily. While GitHub is built on top of Git, it is not the only hosting platform available for Git repositories.


What is Version Control?

Version control is the management of changes to documents, files, or any other types of data over time. In software development, version control is a critical tool that allows developers to manage changes to source code, collaborate with others, and track the history of changes to their code.

Version control systems such as Git, Subversion (SVN), or Mercurial, enable developers to create different versions of their code, including changes, additions, and deletions. These systems track each version of the code, making it possible to revert to an earlier version if needed. Additionally, version control systems enable collaboration by allowing multiple developers to work on the same codebase simultaneously while keeping track of who made which changes.

Version control also provides a mechanism for managing conflicts that arise when two developers make conflicting changes to the same code file. By using a version control system, developers can merge their changes and resolve conflicts in a systematic and efficient manner.

Overall, version control is a critical tool in modern software development that enables collaboration, facilitates efficient development, and helps ensure the quality and reliability of software products.


How many types of version controls we have?

  1. Local Version Control System: A local VCS is a simple database that keeps track of changes to files in a local repository on a developer's computer.

  2. Centralized Version Control System: A centralized VCS stores the code in a central repository, which is accessible to all developers on a team. Changes made by each developer are merged with the central repository.

  3. Distributed Version Control System: A distributed VCS is similar to a centralized VCS, but each developer has a complete copy of the code repository. This enables developers to work offline, commit changes locally, and synchronize their changes with other developers later.


Why 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.


Install Git on your computer

apt-get install git
git --version

Create a free account on GitHub

  1. Go to the GitHub homepage at github.com

  2. Click on the "Sign up" button located in the upper right corner of the page.

  3. On the "Create your account" page, enter your username, email address, and a strong password.

  4. Choose whether you want to sign up for a free personal account or a paid organization account.

  5. If you choose a personal account, you can select your preferred plan. GitHub offers a free plan that includes unlimited public repositories and a limited number of private repositories.

  6. Once you have selected your plan, click on the "Continue" button.

  7. On the next page, you will be asked to verify your email address. GitHub will send a verification email to the email address you provided.

  8. Open the verification email and click on the "Verify email address" button.

  9. Once you have verified your email address, you will be redirected to the GitHub homepage, where you can start using your new GitHub account.


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

  1. Log in to your GitHub account at github.com

  2. Click on the "+" button located in the upper right corner of the page and select "New repository" from the drop-down menu.

  3. On the "Create a new repository" page, give your repository a name, description, and choose whether it should be public or private.

  4. If you want to add a README file to your repository, select the "Add a README file" checkbox.

  5. Click on the "Create repository" button to create your new repository.

  6. On the next page, you will see the repository homepage. Copy the URL of the repository, which is located in the "Quick setup" section.

  7. Open your terminal or command prompt on your local machine and navigate to the directory where you want to clone the repository.

  8. Use the git clone command followed by the URL of the repository to clone the repository to your local machine. For example, if the repository URL is https://github.com/username/repository.git, you can clone the repository by running the command git clone https://github.com/username/repository.git.

  9. Once the repository has been cloned, you can start working on it locally, making changes and committing them to the repository as needed.