All you need to know about Git 🚀
Tags: git, github, beginners
Published: 2020-10-18 20:37:12

###**What is Git?**
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git was created by Linus Torvalds in 2005 to develop Linux Kernel and it is most widely used modern version control system in the world today.

###**What is Version Control System(VCS)?**
Version control systems are a category of software tools that help a software team manage changes to source code over time. 
Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code.
***

###**Following are some essential git commands you must know as a beginner:**
###1] git version
>This command helps you to check your current version of git.
Latest version of git is 2.28.0.
```
Command: git --version
```
***

###2] git config
>git config –global user.name “[name]”
git config –global user.email “[email address]”
This command sets the author name and email address respectively to be used with your commits.
```
Command: git config --global user.name "Viraj Nimbalkar"
Command: git config --global user.email "virajnimbalkar55@gmail.com"
```
***

###3] git config list
>This command helps you to check your configuration settings.
```
Command: git config --list
```
***

###4] git init
>This command is used to start a new repository.
```
Command: git init /viraj/files/git-basics
```
>The folder git-basics will be initialized as a git repository here.
***

###5] git  clone
>git clone [Repository Link]
This command is used to obtain a repository from an existing URL.
```
Command: git clone https://github.com/Viraaaj/Weather-PWA.git
```
***

###6] git add
>This command adds a file to the staging area.
```
Command: git add [filename]  //adds a file to the staging area.
Command: git add .  //adds one or more files to the staging area.
```
***

###7] git commit
>This command records or snapshots the file permanently in the version history.
```
Command: git commit -m “[type Commit message here!]”
```
***

###8] git status
>This command lists all the files that have to be committed.
```
Command: git status
```
***

###9] git log
>Following command is used to list the version history for the current branch.
```
Command: git log
```
---
>Following command helps to view commit history by displaying the first seven characters of the SHA-1 hash and commit message of the commits on the current branch.
```
Command: git log --oneline
```
***

###10] git branch
>Following command is used to list all the local branches in the current repository.
```
Command: git branch
```
---
>Following command is used to create a new branch.
```
Command: git branch [branch name]
```
---
>Following command is used to delete the feature branch.
```
Command: git branch -d [branch name]
```
***

###11] git checkout
>Following command is used to switch from one branch to another.
```
Command: git checkout [branch name]
```
---
>Following command creates a new branch and also switches to it.
```
Command: git checkout -b [branch name]
```
***

###12] git merge
>This command merges the specified branch’s history into the current branch.
```
Command: git merge [branch name]
```
***

###13] git remote
>git remote add [variable name] [Remote Server Link]
This command is used to connect your local repository to the remote server.
```
Command: git remote add origin https://github.com/Viraaaj/Weather-PWA.git
```
***

###14] git push
>git push [variable name] master 
This command sends the committed changes of master branch to your remote repository.
```
Command: git push origin master
```
---
>git push [variable name] [branch]
This command sends the branch commits to your remote repository.
```
Command: git push origin master
```
---
>git push –all [variable name] 
This command pushes all branches to your remote repository.
```
Command: git push --all origin
```
---
>git push [variable name] :[branch name]
This command deletes a branch on your remote repository.
```
Command: git push origin : branch_1
```
***

###15] git pull
>git pull [Repository Link]
This command fetches and merges changes on the remote server to your working directory.
```
Command: git pull https://github.com/Viraaaj/Weather-PWA.git
```
***