πŸŽ‰ Special Offer !    Code: GET300OFF    Flat β‚Ή300 OFF on every Java Course
Grab Deal πŸš€

What is Git


Introduction to Git:

  • Git is an open-source and free version control system that helps manage source code changes efficiently.
  • It was created by Linus Torvalds in 2005 for Linux kernel development.
  • Git tracks changes in files and allows multiple developers to work on the same project.
  • It provides features like branching, merging and reverting changes.
  • It is very efficient, secure and widely used in software development.

Features of Git:

  1. Distributed System -
    • Every developer has a full copy of the repository.
  2. Branching & Merging -
    • Developers can create branches to test features and merge them later.
  3. Speed & Performance -
    • Git processes changes quickly, even for large projects.
  4. Data Integrity -
    • Git ensures every change is tracked and stored securely. It uses cryptographic hashing (SHA-1) for secure data storage.
  5. Efficient Collaboration -
    • Git allows multiple developers to work together seamlessly.
  6. Lightweight & Flexible -
    • Git uses minimal resources and supports various workflows.

Benefits of Git:

  • Git improves the development process by making it more organized and secure.
  • Below are some important benifits of Git :-
    1. Collaboration -
      • Multiple developers can work on the same project without conflicts.
    2. History Tracking -
      • Every change is recorded, making it easy to revert mistakes.
    3. Offline Work -
      • Unlike centralized systems, Git works without an internet connection.
    4. Fast & Scalable -
      • Git handles large repositories efficiently.
    5. Open Source & Free -
      • Available for everyone, with no cost.

Git Workflow & Stages:

  • Below diagram shows the working of Git :-
    Working of Git
  1. Working Directory:
    • This is where you can create, edit, delete and modify files in your project.
    • Changes in this area are not tracked by Git until explicitly added.
    • Command Used:
      • git status β†’ Check which files are modified.
      • git add <file> β†’ Move files from the working directory to the staging area.
  2. Staging Area (Index):
    • It is also known as the Index, this is where Git temporarily stores changes before committing them.
    • It allows you to prepare specific changes before committing.
    • Command Used:
      • git commit -m "message" β†’ Moves files from the staging area to the local repository.
  3. Local Repository (Head):
    • Here, all committed changes are stored in Git's history.
    • This is your local copy of the repository.
    • Command Used:
      • git push origin <branch> β†’ Pushes committed changes to the remote repository.
  4. Remote Repository:
    • It is a central repository (e.g. GitHub, GitLab, Bitbucket) where the project is stored online.
    • Team members can collaborate by pulling and pushing changes.
    • Command Used:
      • git pull origin <branch> β†’ Fetches and merges the latest changes from the remote repository.
  5. Additional Commands:
    • Some additional commands you can use are as follows :
      • git checkout β†’ It moves changes from the repository back to the working directory.
      • git pull β†’ It fetches and updates your local repository with changes from the remote repository.