# #Devops  Day8

Hello, everyone, This is my Eight blog started my day8 as AWS DevOps Engineer #90daysofchallenge with ShubhamLondhe #devops #trainwithshubham.

# **Basic Git & GitHub for DevOps Engineers.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706713701013/dbb63aef-5573-4b23-8e6d-d8b8defe7cce.png align="center")

**Git:-**

Git stand for Global information Tracker. It is basically a version control system.f It is Controlled by a system known as Git Basically a whatever information you want to keep a track off. Git is just a tool that allows u to version control your files, folder, images, etc. E.g. Hello -&gt;version 1 , Hello Dosto -&gt; version 2 .Most of the company in the world are used git to version control their system.

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

## Version Control System

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706723394464/498a6472-e0f2-4e6f-86dd-0f1f0a2fec35.png align="center")

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 2 types of Version Control System. 1. Centralized Version Control System 2. Distributed Version Control System

1\. Centralized Version Control System:-

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. CVCS Few Companies are use. E.g. SVN tool, Bank. We can't over the internet because there is only one central server.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706716283701/bf97e274-7ae2-4363-aa4f-41bc42fd302a.png align="center")

2\. Distributed Version Control System:-

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. Most of the Companies are use DVCS. Files are distributed in multiple computer still we can manage it. Over the internet we can't edit the code. E.g. Git/Github.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706716319489/f218110b-4fea-49a3-a9b3-7a06ee0f4ba0.png align="center")

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

## Task:-

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

## Ans:-

### 1.Create a new repository on GitHub:

### Go to GitHub and log in.

Click on the "+" sign in the top right corner and select "New repository."

Fill in the repository name, description, and other details.

Click "Create repository."

**2.Clone it to your local machine:**

Copy the repository URL from the GitHub page.

Open your terminal or command prompt on your local machine.

Navigate to the directory where you want to clone the repository using the cd command.

Type "git clone" followed by the repository URL and press git clone "[https://github.com/your-username/your-repository.git](https://github.com/your-username/your-repository.git)"

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

1.Make Changes to a File:

Open the file you want to modify using a text editor or any code editor.

Make your changes to the file.

2.Commit Changes using Git:

Open your terminal or command prompt.

Navigate to the repository using cd.

Check the status of your changes using git status.

Add the modified file to the staging area using git add filename or git add .

to add all changes.

Commit the changes with a descriptive message using git commit -m "Your message here".

### #Navigate to the repository

cd path/to/your/repository

### #Check status

### git status

### #Add changes to the staging area

git add filename # or git add .

### #Commit changes with a message

### git commit -m "Updated the file with new content"

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

### *Ans:-Push the file into git: git push -u origin master and it will prompt user and password.*

### *Finally we can see commits in github.*
