Step by step Git hub/repository tutorial in Linux/Mac

In this document i covered full step by step what is git and how it works  and every small topic to understand the git working flow , architecture , Please read the document surely it will help you to play with Git software ,


***Vimp***:   While review this document I request to you guys please read my all mark “Note “it will surely help you to understand deep concept about related topic or terms  


What is the GIT HUB


It is the source version control system for distributed system code and file management which allows to track your changes in project  and git only allows to text based tracking , image ,pdf, ms word is not permitted , please look into the work flow architecture of the Git HUB,



In above diagram you can see the step involve for the GIT version and source control system,

GIT-HUB Allows you to use the GIT in two following ways

1> As version control system

2> Sub version  control management


Version control System :

What do you mean by the verson control system : It is track your code changes between different version , Example like below,

Suppose you have written your code in JAVA and to written this code you used multiple developer, and complete the code with version name V2.0 , Now after some time one of the developer change the code to refine the code property and save it as V2.1, So what git is all about GIT VCS is allow to tract the change code from workgroup or working directory and intimate , Now simply you can use the code in version and save it , GIT VCS is mainly allow to compare code between two version to understand the code and use case,

Different version of the code file name save like below,

Code_V1.0, Code_V2.0, ETC……….

Sub-Version Control system

 It is allow to track your changes and control over network from any where developer and use this to manage the source code.


Step to installing GIT on the Macintosh all version, Step would remain same


Step 1 —Get the Git software download website mention below


http:/     # SCM stand for source code management


Direct download for the mac download please use below URL:


If you facing any issue to install git on any version of OS , Please follow the below link for diagnostic purpose


Step 2 – Installation and configuration GIT on Linux


http:/     # SCM stand for source code management


URL to download the Linux based and install:


If you facing any issue to install Git on any version of OS , Please follow the below link for diagnostic purpose




Now Install and configure the GIT auto completion:


 Step 1    # go the mac terminal and download the Git auto completion.bash script from website:


Cd ~    # go the home directory


 curl -0L


 step4   # Rename the downloaded file

 mv  ~/git-completion.bash ~/.git-completion.bash


step 5:  edit the bashrc_profile ,


vi    ~/.bashrc_profile

Then copy and paste the below code


if [ -f ~/.git-completion.bash ]; then

 source ~/.git-completion.bash



:wq!   # save and exit

step 6

exit from terminal and re open the terminal to make changes


Now starting with GIT command line Commands

Note: Into the GIT configuration every command will start with “ git “

To check the command line available command


~ git help


it will show you the available git command line commands


Note: If you want to see the command specific option so please type the below command


~ git help “command name “


example: if you want to the see the details about the log so command would be


~  git help log


Now Start using Git configuration and more command to learn

 Now initialising GIT repository to track the changes and project

To do so , We will use  “git init “

~ git init    # stand for the the initialization


It initialise the folder or directory to track the changes of project or source code from which location you Initialise your project

Go to the  mac terminal and select any directory location , or it up to you which directory location you want to initialize simply go to that directory and type “git init “  command to initialize the directory to use for tract changes and version of code inside the same directory , 

example: you have directory path   “/User/Atul/Document/git_project”

Note: make sure directory should be exist on your machine

now go to the directory structure ,

on my mac

~  cd /User/Atul/Document/git_project

~ git init

your above directory will initialize.


Note: As soon as you  initialize the Git repository it will automatically create one  .git directory in same path were you initialize the git repository . In my case see the below



If you notice on above ls  -la .git command o/p , .git directory contain 8 properties which is used to taken care by git to track changes of your project. Git directory called the workgroup , and everything regarding to this directory  git will store into this place ,your all tracking is save into this  .git directory

Following is the properties :

  1. Head
  2. Branches
  3. Config #  It is the imp file which we required to use for configure.
  4. Description
  5. Hooks
  6. Info
  7. Object
  8. Refs

Whenever you initialize any directory git automatically created. git along with same properties mention above ,


Now start making changes into your project directory and tell git to add those changes and then commit the changes

Now process how git start to look into changes and in what factor the commit the code ,

As you aware my project directory location is  /User/Atul/Documents/git_1stproject , now I will made some changes into the same project directry called project and then git will follow the below process each and every times if any change will make into the project ,


 1st:  add some changes into current project

2nd: Then git will add there changes into the repository

3rd: as soon as change will add git will commit changes to repository




Now please see the how will do this ,


1st go to the project location where your source code is present , For my case  location is  /User/Atul/Documents/git_1stproject



 2nd:  made some changes into your project , Like intentionally I will do for this document , I will create some file and add some thing into this in same project called Git_1stproject, let do this




3rd: Now git will add this changes or will can track these changes via below command


~ git add .   # . means add changes from current directory



4th: As soo as you will add these changes into git repo , Git  will add these changes into your project on repository via git commit command let do it like

following ,



 Where –m option is for message ,  So each and every times when you will made any changes so via above 4 step process git able to track your changes ,


Now Let understand more about Git architecture

Git have 3-Tier architecture

Layer 1:  Working dorectory   Changes will save of project >3rd

Layer2: Staging index   git commit –m “Message” command >2nd


Layer3:  Repository     Git add command > 1st


In our case


1: Working directory = Git_1stproject

2:  Staging index = it is the middle layer where git store git add command op,

3:   Repository = It can be central repository or isolated repository where all changes save for an individual project. Git save change file as snapshot into Git hash algorithm  “SHA 1” which called checksum


What is checksum ?


Whenever you make any changes into working project directory and apply git add , so git commit to save the changes now as soon as you commit any changes into your project in backed git will generate checksum number 40 character hexadecimal unique number this number will apply to change code or file name and store as snapshot along with same unique checksum , or commit id number ,


Take look below screenshot , how checksum find or look


 Git snapshot :


When you make any changes into your project git will save changes as snapshot and save it into checksum algorithm, Please see the below snapshot parameter


Snapshot – A or 1st change track via git                

commit 7f2c3e5c82d6570a25cb5edb91ca411b67286f50
Parent Nil (for 1st commit)
   Author Atul
Commit Message My first commit


Snapshot –B: 2nf change track via git

commit bb8320f10ad1d180ba9fd838fea965f7ae0f5061
Parent commit 7f2c3e5c82d6570a25cb5edb91ca411b67286f50
Author Atul
Commit Message recently i add some line and change the file


To compare above two snapshot A & B Git is able to track and maintain the change record. Please refer the below screen shot to understand more about the commit and changes that we have made,



Below snapshot is for the reference to see the command line view how it works



 Git imp term – HEAD ?

 Head is pointer which point recently change checksum or commit id head always point new commit code in repository , You can find out HEAD into the our project directory , In my case my project or working directory is

 /User/Atul/Documents/Git_1stproject inside this directory git have  .git hidden directory inside the .git directory we have HEAD , So more understanding please check below screen shot,




 Git Status Command :


It will tell you tracked changes or un-tracked changes from working directory and staging –index

Whenever you add any changes and run git status command it will show you the untracked changes in working directory, Why it show untracked , because once you add any made changes to staging directory then same changed tracking started by the git , So after changes, add the same changes into staging via “ git add “ file name “ or . for all changes , then once again use git status command it will not showing untracked change like earlier it was showing because also added the changes into staging directory , from where git start tracking ,

 Please refer the below scree shot to understand the flow and use of  “git status “

Steps involve to demonstrate the “Git status “ command

no changes added to commit (use “git add” and/or “git commit -a”)

AtulMackbook-pro:Git_1stproject ephesoft$

AtulMackbook-pro:Git_1stproject ephesoft$ #here at above git status op it will show two modefied that i have done recently , under untrack changes now add these modefied file into git staging index via git add “file name” and will see what happen

AtulMackbook-pro:Git_1stproject ephesoft$

AtulMackbook-pro:Git_1stproject ephesoft$ git add 2ndproject_file

AtulMackbook-pro:Git_1stproject ephesoft$

AtulMackbook-pro:Git_1stproject ephesoft$ git status

On branch master

Changes to be committed:

(use “git reset HEAD <file>…” to unstage)

modified:   2ndproject_file

Changes not staged for commit:

(use “git add <file>…” to update what will be committed)

(use “git checkout — <file>…” to discard changes in working directory)

modified:   3ndproject_file

AtulMackbook-pro:Git_1stproject ephesoft$ now only 1 file showing in untract changes if you can see means one file has been saved into git staging index from where it start tracking the changes , now i will do commit the changes for 2nd file and will see the git status oop once again

-bash: now: command not found

AtulMackbook-pro:Git_1stproject ephesoft$

AtulMackbook-pro:Git_1stproject ephesoft$ git commit 2ndproject_file -m ” it is my second commit”

[master 8f4a002]  it is my second commit

Committer: ephesoft <ephesoft@AtulMackbook-pro.local>

Your name and email address were configured automatically based

on your username and hostname. Please check that they are accurate.

You can suppress this message by setting them explicitly. Run the

following command and follow the instructions in your editor to edit

your configuration file:

git config –global –edit

After doing this, you may fix the identity used for this commit with:

git commit –amend –reset-author

1 file changed, 1 insertion(+), 1 deletion(-)

AtulMackbook-pro:Git_1stproject ephesoft$

AtulMackbook-pro:Git_1stproject ephesoft$ git status

On branch master

Changes not staged for commit:

(use “git add <file>…” to update what will be committed)

(use “git checkout — <file>…” to discard changes in working directory)

modified:   3ndproject_file

no changes added to commit (use “git add” and/or “git commit -a”)

AtulMackbook-pro:Git_1stproject ephesoft$ git status



Enjoy 🙂 Thanks

One thought on “Step by step Git hub/repository tutorial in Linux/Mac

  • September 28, 2016 at 5:16 am

    This blog was… how do I say it? Relevant!! Finally I have found something
    which helped me. Many thanks!


Leave a Reply

Your email address will not be published. Required fields are marked *