Understanding Git

Okay, let's start from the very basics.

What is git?


Git is a type of version control system. At least that's what the technical definition says. Putting it in a more understandable manner, git is something which helps you keep track of the changes you make to various files on your computer. Git maintains a record of 'who, when and what'. For eg - if you are working on a group project, git will help you know which friend of yours(Who) made What changes and When. That's one of the reasons for all of us to start using git already.

Now let's say you are working on making a website. You have a basic layout made, and you want to add a little more functionality to it but unfortunately the code you write for this fails to work and now the whole website code has become a mess. This is where 'version control' comes to your rescue. Git, a type of this version control system helps to keep all the versions of the files which means you can easily go back to the basic layout without having to worry to clean your code of the various changes you made.

How to use git?
Here, I won't go into the details of it because many tutorial videos do this job better, the links of which I have attached at the end of this post. However, let's understand that just as a pencil is to pencil box same way is git to Github(or Bitbucket).
Git is the collection of all the versions of your file system. You can maintain this on your local computer and Github or Bitbucket is just a way to maintain this online.

Git terminology in brief
local repo - the one on your computer
remote repo - the one on github or any other git host platform
branch - a parallel or independent line of development which lets you work on the project in an isolated space
origin - name given to the primary version of a repository
master - main default branch of any repository
commit- a commit is a snapshot or state of your project and by committing files to a repository, we mean to submit files to the local repository(the one on your pc)
clone - downloading a copy of an existing repository usually from an online repository to your local computer
push - submitting files to the remote repository(the one on github or bitbucket) checkout - checkout command switches between branches or restores working tree files
pull - Pull operation copies the changes from a remote repository instance to a local one. You might call it as updating the changes to your local repository from the remote repository
fetch - similar to pull, however, fetch only downloads the data from the repository it does not integrate with the files you're currently working with.
head - the topmost or the most recent commit on a branch of a repository

A basic layout of how things work

Git architecture


A repository is the place where all the versions are stored and workspace is your working area. The Staging area is where your work goes when it is prepared, but still not given a final green flag. The green flag, the final version goes to the .git repository (after we commit it). You checkout code from the repository to the working directory and commit changes you’ve made in this working directory back into a new version of the content in the repository.

A few tutorial links to get you started with Git and Github:
https://youtu.be/SWYqp7iY_Tc
https://youtu.be/xuB1Id2Wxak
https://youtu.be/0fKg7e37bQE