What is Git and how its different from GitHub?

What is Git and how its different from GitHub?

Introductory blog

When I first learnt about Git and Github from Youtube, I made handwritten notes about them. I thought I can share the photos of my notes on LinkedIn but actually, my writing is not too good nor my presentation is so beautiful, so today I decided to write that notes in the form of a blog.

Here I present you my today's blog on What are Git and GitHub ? and how they are different from each other.

What is Git?

Git is a version control system that allows one to track changes to files and coordinate his work on those files with multiple people.

With Git, one can keep a record of who made changes to what part of a file, and he can revert back to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as one can share changes and merge the changes made by different people into a single version of a file.

What is GitHub?

GitHub is a web-based platform that provides hosting for version control using Git. It is a subsidiary of Microsoft, and it offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.

What is a Version Control System?

Version control is a system that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.

There are two main types of version control systems: centralized version control systems and distributed version control systems.

Centralised version control systems

A centralized version control system (CVCS) uses a central server to store all the versions of a project's files. Developers "check out" files from the central server, make changes, and then "check in" the updated files. Examples of CVCS include Subversion and Perforce.

Drawbacks

  1. It is not locally available meaning you always need to be connected to a network to perform any action.

  2. Hence, everything is centralised, if your central server gets failed you will lose the entire data. Example SVN tool.

Distributive version control system

In distributive control system. Every distributor has a local copy or clone of the main repository i.e. everyone maintains a local repository of their own, which contains all the files and metadata present in main memory.

CVCSDVCS
In CVCS, a client needs to get a local copy of the source from the server. Do changes and commit those changes to a central source on the server.DVCS each client has a local repo as well as a complete history on it. The client needs to push the changes to the branch which will be then pushed to the server repository.
CVCS systems are easy to learn and set up.DVCS Systems are difficult for beginners. Multiple commands needed to be remembered.
Working on branches is difficult in CVCS, developers often face merge conflicts.Working on branches is easier in DVCS, developers face less conflict.
CVCS systems do not provide offline access.DVCS systems are working fine on offline mode as a client copies the entire repository on their local machine
CVCS is slow as every command needs to be communicated with the server.DVCS is faster as most users deals with a local copy without hitting the server every time
If the CVCS server is down, developers cannot workIf DVCS Server is down, developers can work using their local copies.

Stages of git and its terminologies.

  • Git is a DVCS.

  • Built by the same person who built Linux.

  • GitHub and GitLab are services.

Stages of git/workflow

Repository

A repository is a place where you have all your quotes or kind of folder on the server.

  • It is a kind of folder related to one product.

  • Changes are personal to the particular repository.

Server

  • It stores all repositories.

  • It contains metadata also.

Working directories

  • Where you see files physically and do modifications.

  • At a time, you can work on a particular branch.

On the other hand in CVCS developers generally make modifications and commit their changes directly to their repository, but it uses a different strategy. Git does not track every modified file, whenever you commit an operation, it looks for the file present in the staging area, only those files present in the staging area are considered for commit and not all the modified files.

Commit

  • Stores change in the repository. You will get one commit id.

  • It is 40 alphanumeric characters.

  • It uses the SHA-1 checksum.

  • Even if you change one dot, the commit id will change.

  • It helps you to track the changes.

  • Commit is also named SHA-1 hash.

Commit ID/ Version ID/ Version

  • Reference to identify each change.

  • To identify who changed the file.

Tags

Tags assign a meaningful name with a specific version in the repository. Once a tag is created for a particular save, even if you create a new commit it will be updated.

Snapshots

  • Represent some data of a particular time.

  • It is always incremental i.e. it shows stores The changes small changes (append data) only, not the entire copy.

Push

Push operation copies changes from a local repository server to a remote or central repo. This is used to store the changes permanently in a git repo.

Pull

Pull operation copies the changes from a remote repository to a local machine. The pull operation is used for synchronisation between two repo.

Branch

  • The product is the same, so one repository, but a different task.

  • Each task has one separate branch.

  • Finally, merge all branches.

  • Useful when you want to work parallelly.

  • Can create one branch based on another branch.

  • Changes are personal to the particular branch

  • The default branch is master.

  • File created in workspace will be visible in any of the branch workspace until you commit, that file belongs to that particular branch.

Advantages of GIT

  • Free and open source

  • Fast and small as most of the operations are performed locally. Therefore it is fast.

  • Security: Git uses a common cryptographic hash function called secure hash function SHA-1. To name and identify objects within the database.

  • No need for power hardware.

  • Easier branching: If we create a new branch, it will copy all codes to a new branch.

Types of Repository

Bare Repository (Central Repo)

  • Store and Share only.

  • All central repos are bare Repo.

Non-Bare Repository

  • When you can modify files.

  • All local Repo. are non-bare repo.