# Git for Beginners: A Comprehensive Guide

**Git is a distributed version control system (DVCS)** for tracking changes in any set of files. It is designed to handle very large projects with lots of contributors. Git is used by many open-source projects, including the Linux kernel, the Ruby on Rails framework, and the Android operating system.

Git commands are used to manage a Git repository. They can be used to create, add, commit, diff, checkout, merge, push, pull, and reset files and branches in a repository.

Here are some of the most commonly used Git commands:

* `git init`: Creates a new Git repository.
    
    ```bash
    git init
    ```
    
* `git clone`: Clones an existing Git repository to your local machine.
    
    ```bash
    git clone https://github.com/Jatinkc/git-repo
    ```
    
* `git add`: Adds files to the staging area.
    
    ```bash
    git add file.txt
    git add . #adds all the files in the directory to the staging area
    ```
    
* `git commit`: Commits the changes in the staging area to the repository.
    
    ```bash
    git commit -m "added file.txt"
    ```
    
* `git diff`: Shows the differences between the working directory and the staging area, or between two commits.
    
    ```bash
    git diff file.txt
    ```
    
* `git checkout`: Checks out a specific commit, branch, or tag.
    
    ```bash
    git checkout mybranch
    ```
    
* `git merge`: Merges two branches together.
    
    ```bash
    git merge mybranch
    ```
    
* `git push`: Pushes changes from your local repository to a remote repository.
    
    ```bash
    git push origin
    ```
    
* `git pull`: Pulls changes from a remote repository to your local repository.
    
    ```bash
    git pull
    ```
    
* `git reset`: Resets the working directory to a specific commit, branch, or tag.
    
    ```bash
    git reset 9a9add8
    ```
    

> `9a9add8` indicates a commit id used to revert back discarding all the changes after that commit

### **To practice a Hands-On refer to the below links,**

1. [Learn Git Branching](https://learngitbranching.js.org/)
