# Some Useful Git Commands you should Know 🚀



> Git is very popular version controlling system almost used by every developer to manage their code efficiently and keep the track record of the commit in codebase by time. The place where we store the code could be Github, GitLab, BitBucket or AzureDevOps . No matter if you are beginner or experienced developer , these are the commands that every developer should know. So lets start.

---

# Git Commands 
 

1.
`git config [ options ]`
This command helps you set the username and email address to be used with your commits respectively.
      
       
  ```
  git config --global user.name "ZeffK"
  config --global user.email "Zeff@dev.com"
  ```
---

2.
`git init [ repository name ]`
This command initializes a repository as git repository. To perform git operations you need to initialize the target repository as a git repository.


 ```
git init /home/zeff/Documents/iwritecode
```
  
  The folder `iwritecode` will be initialized as a git repository here.
  Alternatively you can go into that repository and then initialize it by simply giving the command git init

---

3.
`git clone [ URL ]`
This command is used to download an existing repository from a server by an existing URL.

```
git clone https://github.com/ZeffK/ReactLearning.git
```

---

4.
`git status`
This command is used to see the status of the working tree. It shows you the list of unstaged files and list of files that needs commit. If there is nothing do then it will simply show that the branch is clean.
```
git status
```

---

5.
`git add [File Name]`
This command puts the desired file to the staging area if any changes are made in that file.

```
git add app.js
```
---

6.
`git commit [options]`
This command records changes to the git repository by saving a log message together with a commit id of the changes made.

```
git commit -m "Write your message here"
```

---

7.
`git push [ options ] [ variable name ] [ branch ]`

This command is used to push the contents of your local repository to the added remote repository. This sends the committed changes of your master branch to the added remote repository.

```
git push -u origin main
```
Note- `-u` denotes upstream i.e to keep track of file with origin

---

8.
`git pull`
This command is used to fetch and integrate the contents of the remote repository to your local repository.
```
git pull
```

---
9.
`git checkout [ branch name ]`
This command is used to move from one branch to another
```
git checkout dev
```
---

10.
`git branch [ options ] [ branch name ]`
This is used to create a new branch from existing branch and to switch to newly created branch

```
git branch -b newbranch

```
---

>*For all git commands you can refer to [Git Docs](https://git-scm.com/docs/git)*

###  Follow me on [Instagram](https://instagram.com/qazi_958)















