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

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

What is Git?

  • Git is a version control system that allows you to track changes to files and coordinate work on those files among multiple people. It is commonly used for software development, but it can be used to track changes to any set of files.

  • With Git, you can keep a record of who made changes to what part of a file, and you can revert back to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as you can share changes and merge the changes made by different people into a single version of a file.

What is Github?

  • GitHub is a web-based platform that provides hosting for version control using Git. It is a subsidiary of Microsoft, and it offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.

What is Version Control? How many types of version controls we have?

  • Version control is a system that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.

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

  1. A centralized version control system (CVCS) uses a central server to store all the versions of a project's files. Developers "check out" files from the central server, make changes, and then "check in" the updated files. Examples of CVCS include Subversion and Perforce.

  1. A distributed version control system (DVCS) allows developers to "clone" an entire repository, including the entire version history of the project. This means that they have a complete local copy of the repository, including all branches and past versions. Developers can work independently and then later merge their changes back into the main repository. Examples of DVCS include Git, Mercurial, and Darcs.

Why we use distributed version control over centralized version control?

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

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

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

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

Task:

Git install🖥️

Creating Git account

  • Create a free account on GitHub (if you don't already have one). You can sign up at https://github.com/

Learn the basics of Git by reading below information. This will give you an understanding of what Git is, how it works, and how to use it to track changes to files.

  • Let's understand Git and GitHub. Whether you're a developer or a DevOps engineer, knowledge of Git is crucial. Developers frequently write extensive code, and proper code management becomes essential. If, for instance, some code for a website is accidentally deleted, GitHub allows us to retrieve it. It serves this purpose by providing version control and enabling the restoration of lost or deleted code.

  • Git and GitHub are separate entities. Git is a version control tool that enables you to manage versions of your code. Version control means storing significant code changes. For instance, imagine you've uploaded important code for an application and later decided to modify it. If someone accidentally deletes this altered code folder, your data is lost. To prevent such mistakes, a sophisticated version control system is required. Git allows tracking the history of code changes, showing when modifications occurred, what was added or deleted, and even recovering deleted code.

  • GIT: Git is a version control system that helps you manage the versions of your code and files. It provides detailed records of modifications, creations, deletions, and timestamps for every change. Git should be known to all programmers because of its extensive tracking features.

  • GitHub: GitHub is a platform where developers and DevOps engineers store their code, allowing others to access and run applications. To install GitHub, you can use this link➡️https://github.com/

This will give you an understanding of what Git is, how it works, and how to use it to track changes to files.

Exercises:

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

  • Open your GitHub and create a repository and click on ➕ and then click on the new repository

  • Enter your repository name and description, add a README file, and click on Create Repository.

  • After that open your repository and copy that code link

  • Open your terminal and do clone git clone <repository link>

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

  • create a file practice.txt and write this is git

Bash

# vim practice.txt
this is git

Bash

git status

Bash

git add practice.txt

Bash

git commit -m "added new practice"

Push the changes back to the repository on GitHub

Bash

git remote -v

Bash

git remote set-url --add origin https://<github token>@<github code link>

Bash

git remote -v

Bash

git remote set-url --delete <name> <url>

Bash

git push origin main

Note:- Using a token you can push the repository


Happy Learning

Thanks For Reading! :)

-SriParthu💝💥