Git Introduction

Git is a distributed version control system that tracks changes in computer files. It's primarily used for software development, but can also be applied to other projects that involve managing and tracking changes in files.

Git is built using C.

Git is like a digital backpack for your projects(Files). It stores all your files, changes, and versions, allowing you to carry them around and access them whenever you need. Inside your backpack is a magical compartment.

Version Control - Keeps track of changes.

When was Git created?

Git was created by Linus Torvalds in 2005. It was originally designed to manage the development of the Linux kernel, but it quickly gained popularity and became a widely used version control system.

The name "Git" is derived from the word "Linus," a reference to its creator, Linus Torvalds, who is also the creator of the Linux operating system.

Where is GIT mainly used?

  • Software development
  • Data analysis
  • Writing and editing
  • Web development
  • Design

Why use Git instead of just a computer?

Collaboration (Shared Backpack)

  • Computer: Multiple people can access the same files, but it's difficult to merge changes.
  • Git: Multiple people can work on the same project simultaneously, and Git helps merge their changes and resolve conflicts.

Version Control (Time Machine)

  • Computer: You save multiple versions of your files with different names.
  • Git: Git automatically saves snapshots of your project at different points in time, so you can easily go back to a previous version.

Time Travel - Restore Previous Version

  • File History

Distributed Nature (Multiple Backpacks)

  • Computer: You have a single copy of your files.
  • Git: Each person working on the project has a complete copy of the project, making it more reliable and faster to work with.

All the files are cloned.

Branching and Merging (Multiple Pockets)

  • Computer: You can create copies of your project for different experiments.
  • Git: Git allows you to create separate branches (like pockets) for different features or experiments. You can then merge these branches back into the main project when you're ready.

Experimenting is easier. You can rectify your past. It is like going back in time and making changes on it.

Git aids in

  • Loss of Work
  • Difficulty Collaborating
  • Lack of History
  • Increased Risk of Errors
  • Reduced Efficiency

How to Use Git

Image Description Image Description Image Description

Installation

  • Download Git from the official website https://git-scm.com/download
  • Follow the installation instructions for your operating system.
  • Applying Locally

    Git Initialization

    Navigate to your project directory in the terminal.

    git init
                                

    Commit

    Add your changes to the staging area:

     git add .
                                

    Commit the changes to your local repository:

    git commit -m "Your commit message"
                                

    Applying Remotely

    Use GitHub

    Create a new repository on GitHub.

    Push to GitHub

    Add the remote repository to your local repository:

    git remote add origin https://github.com/your-username/your-repository.git
                                

    Push your local commits to the remote repository:

    git push -u origin "branch-name"
                                

    Clone

    Clone the remote repository to your local machine:

    git clone https://github.com/your-username/your-repository.git
                                

    Pull

    Pull the remote repository to your local machine:

    git pull https://github.com/your-username/your-repository.git "branch-name"