# Git for Beginners: Basics and Essential Commands

* What is Git
    
* Why Git is Used
    
* Git Basics and Core Terminologies
    
* Common Git Commands
    

---

## Understand GIT and its Uses

Git is a version control system that manages operations like modifications, updates, changes, removals, history, and many more in a specific folder, repository, or directory. ( **Folder , Repository and Directory are having same meaning** )

---

## What are the Terminologies used inside Git ?

* **Repo** - It's like a folder where your files are stored.
    
* **Staging Area** - When you update your files and want Git to track them, you move the specific file to the staging area.
    
* **Commit** - When you are ready to save the updated changes of a particular file, you first need to commit that file, and it will then be added to your repository.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767793107966/79f6d9ab-24d8-4648-9311-5f246004f2d5.png align="center")
    
* **Branch** - It's like different timelines existing together but not affecting each other.
    
* **Merge** - When you want to bring content from a different timeline (Branch) into your timeline (Your Branch), you need to merge it.
    
* **Head** - It's like a marker or pointer that shows your current location, position, or what you are currently working on.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767794468801/f5c14209-bca7-4998-acaa-3ea709851df2.png align="center")
    
* **Commit History** - It's like a record of everything you have done in your file, including updates, removals, additions, merges, modifications and many more.
    

---

## Common Git Commands

* git init -Turn your folder into a Git repository by initializing a .git file inside it.
    
* git add &lt;your fileName&gt; - Will place your file in the staging area, making it trackable.
    
* git add . - Will move all the files in the working folder to the staging area, no need to mention specific names of the files.
    
* git commit -m “Your message” - This will save your final changes to the repository.
    
* git commit -am “Your mesage” - This is a very **important command** to know. It first pushes the files into the staging area and then commits them with a message. The "**Cache**"is that this command only pushes files into the staging area if they are already being tracked by Git. So, if you create a new file and run this command, it won't push the new file into the staging area. However, if you have modified files, it will work on those.
    
* git branch - Shows you which branch (timeline) you are currently on.
    
* git status - This command will show you the status of your files, such as which ones are tracked, untracked, or modified.
    
* git log - Provides the complete history of your files and the operations you have performed so far.
    
* git revert &lt;hashId&gt; -Will make a complementary commit for the changes that happened in the mentioned `<hashId>` and won't remove the history.
    
* git reset —hard &lt;commitId&gt; - This is similar to revert, but here no complementary commit is created. It simply removes all the history and takes you to the specified `<commitId>`.
    

There are more command that exists you can check them on [Git official documentation](https://git-scm.com/docs).

---

## Flow Diagram of Commit History

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767797555931/bb36217f-9165-4903-8091-d2cb0177712f.png align="center")

---

## Conclusion

We understand the terminology of Git, the staging area, branches, commit history, and various Git commands.
