Day 8 : Basic Git & GitHub for DevOps Engineers.
Tags: github, git, beginners, devops
Published: 2024-06-09 11:20:30

**What is Git?**
Git is a free open source distributed version control system you can use to track changes in your files. You can work on all types of projects in Git, from small to large.

With Git, you can add changes to your code and then commit them (or save them) when you're ready. This means you can also go back to changes you made before.

**What is Github?**
GitHub is a web interface where you store your Git repositories and track and manage your changes effectively. It gives access to the code to various developers working on the same project. You can make your own changes to a project at the same time as other developers are making theirs.

If you accidentally mess up some code in your project while making changes, you can easily go back to the previous stage where the mess has not occurred yet.


**What is Version Control? How many types of version controls we have?**
A version control system is a software that tracks changes to a file or set of files over time so that you can recall specific versions later. It also allows you to work together with other programmers.

The version control system is a collection of software tools that help a team to manage changes in a source code. It uses a special kind of database to keep track of every modification to the code.

Developers can compare earlier versions of the code with an older version to fix the mistakes.


**Two Types of Version Control System-**

1.Centralized Version Control System.

2.Distributed Version Control System.


**Centralized Version Control System-**

The developers needed to collaborate with other developers on other systems.To deal with this Centralized Version Control System were developed.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/za8y5w55m3zdjcf3d889.png)
Centralized Version Control System uses a central server to store all the database and team collaboration. But due to single point failure, which means the failure of the central server, developers do not prefer it.


**Distributed Version Control System-**

The user has a local copy of a repository. So, the clients don't just check out the latest snapshot of the files even they can fully mirror the repository. The local repository contains all the files and metadata present in the main repository.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9qagijloh4a3avysb2h.png)

DVCS allows automatic management branching and merging. It speeds up of most operations except pushing and pulling. DVCS enhances the ability to work offline and does not rely on a single location 
for backups. If any server stops and other systems were collaborating via it, then any of the client repositories could be restored by that server. Every checkout is a full backup of all the data.

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

In centralized version control, the versions are saved in the remote repository, while in distributed version control, versions can be saved in the remote repository as well as in local repositories of the local machines.so we prefer DVCS over CVCS.

**Task:**

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sb2szt2rj8t25fpeakiy.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zach3yrpxp9lzhpm69ps.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xfw6wfpgystjra9rifv0.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5lkic7hdl0vpdxiadt19.png)

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

made changes to "fromgithub"

**git init**=To make new git repo/git-init - Create an empty Git repository or reinitialize an existing one.

**git add** fromgithub==Ready to be staged

**git commit -m** "Added changes"==To save changes.

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

**git push origin master** ===To push from Local to remote.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/id32r9jyjuvv0sh1usw6.png)

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