Getting started with Git and Github
Tags: git, github, webdev, codenewbie
Published: 2022-04-30 15:45:52


## Intro

## version control
 
 Version control is also known as revision control /source control is a class of systems responsible for managing changes to your files.

### Types of version control system


 1. Centralize version control systems
 2. Distributed version control systems

### Centralized version control system


 CVCS have only one central repository. Repository is basically a server which all the file and history are stored. The machine can access the repository via LAN and WAN.

 Example of CVCS:

   1. Concurrent version system (CVS)

   2. Subversion (SVN)

![cvcs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6538zegx26auu19zz4r.png)
<!--an image of CVCS-->

### Distributed version control system

DVCS don't require a central server that contain repository. Every user has its own repository called *local repository*.

Example of DVCS:

1. GIT
2. Bit-keeper

![dvcs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7lf35p9s4iad77g2y3t.png)

### What is git ?
 GIT is a decentralized version control system used to keep changes of your file.

 GIT was developed by *Linus Torvalds* in 2005 for efficient code management and version control of their project. Understanding basic commands of git could help you in storing your projects in your local repository and pushing them into your remote repository.

### Git installation

 **.Windows**

[Download git for windows](https://git-scm.com/download/win)
 

 **.Mac**

[Download git for mac](https://git-scm.com/download/mac)


**.Linux (Debian)**

 ` $sudo apt-get install git `

### Git commands
 

 The following are basics commands of git.

### git config
 
 This command is used to set user configuration such as user-name and user-email as shown below:


![git config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bctdrf92wja92yvt2tkc.PNG)
 

### git init
 

 This is one of the common git command you will be using. Its used to initialize local git repository.


![git init](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3hb5i8ymgc5402r59bfd.PNG)
 

### git add
 

 The command **git add** is used to add the file into local repository for example below the *.index* will be added to local repository:


![git add](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sg6dolc59jo4e2ef8z4o.PNG)
 

### git status


 This **git status** command is used to check status of working tree. Below you see three file which are untracked:


![git status](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwnwuu0r1ze5osdl427s.PNG)
 

### git commit
 

 The **git commit** command is used to commit in the staging area. The committed changes will now go to remote repository. Example:


![git commit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fe0e558z4q1r6kzjx3b.PNG)
 

### git push


 Once the files have been committed the **git push** command is used to push the files to remote repositories:


![git push](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wfoq7g6m2zjh4bi3m3pf.PNG)
 

### git pull
 

 The command **git pull** is used to fetch/merge content in remote repository into local repository:

 `git pull`

### git clone
 
 This command is used to download existing git repository into your local repository. For example below the **git clone** command will download the files from existing remote repository to local repository(basics of git):


![git clone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wx4gw2ob2o5ycpkizt07.PNG)
  

### git rm
  

  The command **git rm** will delete or remove the file from repository: Below we can see the file *.index* removed:


![git rm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c77l7flchjr8sqjlpet2.PNG)
  

### git branch
This command is used to create a new branch. Example **git branch** will create new branch called myapp:


![git branch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pb2jcb0k8itkmolh7d5r.PNG)
<!--img for git branch-->

### git checkout

This command help you to navigate from one branch to another. Example we used **git checkout** to navigate from *master* branch to *myapp* branch:


![git checkout](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6e5eajunihovj9rl7h5f.PNG)


### git merge

The **git merge** is used to integrate two branches together. It will merge one branch to another active branch. Below we have merge *myapp* to *master* branch:


![git merge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hpco1rww9k9agmiye57f.PNG)