What is Version Control System?
Tags: git, github, bash, code
Published: 2021-08-25 18:08:43

A version control system(VCS) is a tool or software that helps to manage different versions of the source code. A source code manager is another name for a version control system.

In other words Version control is a system that carries all the records of file changes or sets of files with respect to time so that we can easily switch to previous versions later.
## What is Git?
![altText](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7oobpoqvzhr63qmte72p.png)

Git is a type of version control system (VCS) that helps to track the file changes in an easy manner. Git is a free and open-source distributed version control system that has a simple UI design that everyone can understand easily. With the help of Git, we can track small to very large projects with speed and efficiency.
![gitWorkflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkky3jirg7b75ncofv1y.png)
* **A repository** is a Collection of the Source code or files of the project work, Repositories can exist either in the local environment or in the form of a remote copy on another computer. A repository is made up of commits.
* **Working Directory** is the source code or files that you see in your computer's file system. When you open your project files upon a code editor, you're working with files in the Working Directory.
* **Staging Area:** A Stage all Changes in the Current directory that stores information about Changes that you commit. You can think of the staging area as a prep table where Git will take the next commit.
* **Branch** is a new line of development is created that diverges from the main line of development. This alternative line of development can continue without altering the main line.

### How To Setup Git?
**To download Git**
1. Go to [Git-scm.com](https://git-scm.com/downloads)
2. Download Git Acc. to the Operating system
3. install Git choosing all of the default option

**Open GitBash**
#####First Time Git Configuration
```
# sets up Git with your name
git config --global user.name "<Your-Full-Name>"

# sets up Git with your email
git config --global user.email "<your-email-address>"
```
Create a new project.Open git bash in project directory then initialize project
```
git init
```
The git init command creates a new Git repository or initialize a new, empty repository.
* **touch** - used to Create a new file
* **ls** - used to list files and directories
* **mkdir** - used to create a new directory
* **cd** - used to change directories
* **rm** - used to remove files and directories

### Create A Web Project 
* create an index.html file
``` 
touch index.html
```
* create a javaScript file
``` 
touch main.html
```

* create a style.css file
``` 
touch style.css
```
![github](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oq0dg4uszsv3ezdi05bt.png)

```
git status
```
![gitcommits](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jd4fx83k6hgs9jfw4o9.png)
 
* **git status** command displays the state of the working directory and the staging area.

```
git add .
```
* **git add** command adds a file to the Git staging area.
```
git commit - m "initial commit"
```
* **git commit -m** Used to Save Your changes in local repository.

## some Important git Commands

![gitcommands](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02e6z1u5rz9muy55o5u3.png)