Understanding Git using Bank Theory.
Git is an open-source version control system tool developed by Linus Torvalds in 2005. It is used for tracking changes made in files. It’s software preferred by the developers which allow the user to make an edit and create repositories. For a better understanding let’s learn about the version control system.
As we have a better understanding of this term, let us connect them with our Bank Theory.
Uneritx Bank of India
We will create a new directory named uneritx-bank. Equivalent to constructing a bank building.
$ mkdir uneritx-bank
Now that we have the Bank infrastructure ( Directory ) ready, we will now initialize the Uneritx Bank Operations. ( Initializing the Repository )
$ cd uneritx-bank
$ git init
Just like every Bank has a Manager, similarly, we will appoint a manager for our Bank.
( Configuring the Repository ).
$ git config --global user.name manager_name$ git config --global user.email manager_email@uneritx.com
Now we will create a branch named head-office using git branch Head-office.
( Creating a Master Branch )
$ git branch head-office
A person named Mickey is standing outside the bank building and filling the Account Application form i.e. mickey. ac.
( Creating a File outside the Bank Repo Directory )
$ pwd /home/shivani/
$ touch mickey.ac
$ ls -la /home/shivani/
-rw-r--r-- 1 shivani shivani 322 May 18 2020 README.md
drwxr-xr-x 4 shivani shivani 4096 Apr 9 2020 uneritx-bank
-rw-r--r-- 1 shivani shivani 1684 Sep 21 2020 mickey.ac
But wait, For Bank to “track” the user application, the user must enter the Bank Premises.
( Moving the mickey.ac file to uneritx-bank local repo directory )
$ mv mickey.ac uneritx-bank
Now that the user has entered the Uneritx-Bank Premises, let’s see what document is he actually carrying.
( Checking the Untracked Files in the Uneritx Bank Repo )
git status On branch head-office No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) mickey.ac
The document ( mickey.ac ) seems to be a valid application form and can be accepted to the Account Opening Counter ( i.e. the Staging Area ).
( Adding the file to the Staging Area of the Uneritx Bank Repo ).
$ git add mickey.ac
Its time for the Bank employee to open a Bank Account by “committing” the account details in the “Bank Database”.
( Committing the file to the Bank Repo Head-Office branch )
$ git commit -m "Opened Bank Account for user Mickey"
We will now create a new branch of our bank in Delhi. ( With the existing records from head-branch )
$ git checkout -b delhi
We will now create two users at our Delhi branch, tom.ac and jerry.ac .
$ git branch * Delhi head-office
$ pwd /home/shivani/uneritx-bank
$ touch {tom,jerry}.ac
We have to add and create ( commit ) their account to the bank’s database.
$ git add tom.ac jerry.ac
$ git commit -a "Account opened for Tom & Jerry"
As branch Delhi is a child branch of Head-office we have to ensure that the head-office branch database gets updated with the new accounts records. For this, we must know about the Git Rebase & Git Merge concepts.
In the upcoming blog, we will be discussing Git Rebase Vs Git Merge.