# Basic Commands In Git

In the previous [section](https://blog.teachmebro.com/getting-started-with-git-installing-git-client) we have `installed` Git on our system. In this section, we will see some basic `commands` in Git. we will use these commands in the next section, here our aim is to know what are the commands in git and what is their `usage`.

Basic Git Commands:
===================

### **1) git init**

**Utility**: To initialize a git repository for a new or existing project.

**How to**: git init in the root of your project directory.

**Example:**

```
git init
```

### **2) git clone**

**Utility:** To copy a git repository from a remote source, it also sets the remote to original source so that you can pull again.

**How to:** git clone <:git url:>

**Example: **

```
git clone https://github.com/altafshaikh/Friends-The-Social-Network.git
```


### **3) git status**

**Utility:** To check the status of files you've changed in your working directory, i.e, what all has changed since your last commit.

**How to:** git status in your working directory. lists out all the files that have been changed.

**Example:**

```
git status
```

### **4) git add**

**Utility:** adds changes to stage/index in your working directory.

**How to:**

```
git add .
```

### **5) git commit**

**Utility:** To save changes to the local repository safely. Commit takes a snapshot of the project and treats it as a version.

**How to:**

```
git commit -m "sweet little commit message"
```


### **6) git push**

**Utility:** It is used to transfer or push the commit, which is made on a local branch in your computer to a remote repository 

**How to:** git push <:remote:> <:branch:>

**Example:**

```
git push origin master
```

### **7) git pull**

**Utility:** It is used to fetch and download content from a remote repository and immediately update the local repository to match that content.

**How to:** git pull <:remote:> <:branch:> 

**Example:**

```
git pull origin master
```

### **8) git --version**

**Utility:** To check the version if the git is installed

**How to:**

```
git --version
```

### **9) git remote**

**Utility:** To check what remote/source you have or add a new remote.

**How to:** git remote to check and list. And git remote add <:remote_url:> to add a remote.

**Example: **

```
git remote add https://github.com/altafshaikh/Friends-The-Social-Network.git
```

​`Congratulations!! We have learned basic commands of Git and now we are ready to use them and see Git in action, in our next section.`

​
