Skip to content

Why Git?

Let's go back in history.

Pahle ke jamane me jab koi dev hona hota tha tab bahut se log milakar kaam karte the likin, jab koi aana kaam kar ke code bhej deta tha tab usko code ko baki logo ke code me merge karna bahut muskil ka kaam hota tha. For example, ek team me 10 log kaam kar rahe hai aur unn sabka ek manager hai, aur sab bande apana apana code apane us manager ko daily bhejte hai, us manager ka kaam ye hai ki sabhi ke code ko dekhna aur sabka track rakhna ki kab kisne kya update kiya code me to ye sab amnually karna bahot muskil ka kaam hai.

Is problame ko solve karne ke liye ek term aayi - Source Code Management

  • Source code management hamare code ke versions ko sambhal ek rakhta hai.

For exmple:

Version1 ->

import abc

Version1.1 ->

import abc
x = "Rishabh"

Source Code Management

Ye 2 type ka hota hai

1. CVCS - Centralised Version Control System

Earlier this was used before Git.

Example - SVN

Some Terminologies

  1. Repository - Ek central location hoti hai jahan project ka complete versioned code + history store hota hai (usually remote server pe).
  2. Commit - Code ke changes ko central repository (server) me permanently save karna Git me commit local hota hai, CVCS me commit = server pe save
  3. Update - Central repository se latest changes apni local working copy me lana. (Agar pahli baar hai to pura code aayega aur next time se sirf updated code aayenge)

Is system me ek centralised storage system hota hai, jaha pe sabhi team member apana apana code commit(Save) kar sakte hai.

  • Ise samajhane ke liye, suppose 3 log ek project poe kaam kar rahe ha, aur PC1 ne kuch kaam kiya aur centralised storage pe save kar diye, similarly PC2 ne bhi apana kaam kar ke waha pe save kar diya etc...
                     CENTRAL REPOSITORY
                  (Remote Server / SVN)
                 ──────────────────────
                         │  Commit (Upload)
        ┌───────────────┼───────────────┐
        │               │               │
        │               │               │
      PC-1            PC-2            PC-3
   (Developer1)    (Developer2)    (Developer3)
        │               │               │
        │               │               │
        └───────────────┼───────────────┘
                         │  Update (Download) from the same repoto local
                 Latest Code Changes

Aavantages

Ab is system me fayada ye hai ki isase sabhi bando ko faayada ho jata hi ki, sab sabka code dekh sakte hai, aur apana apana kaam sahi se kar sakte hai, For ex:

  1. PC1 - ne kuch code commit kiya
  2. Ab PC2, PC1 ka code dekh sakta hai aur uske according apana kaam kar sakta hai.

ye bilkul aisa hai jaise, code ko kisi aisi jagar pe rakh rahe hai jaha se, hamare commit(Save) karne ke baad us code ko sab dekh sakte hai.

Us samasy to ye bahut hi achha system hua karta tha lekin dheere dheere iski kamiya saamne aane kagi

Drawbacks

  1. Code is not locally available (maybe kuch copies aapke machine pe padi hongi but overall complete code Remote server pe hoga)
  2. Kya ho agar Remote server(central storage system) hi kharab ya corrupt ho jaaye
  3. Remote server ko access karnenke liye internet chahiye uske bina na code save kar paayenge na hi waha pade code ko dekh sakte hai

TL;DR

CVCS me poora project ek central server pe hota hai, local copy nahi hoti. Agar server down ya internet na ho, to developers ka kaam ruk jaata hai. Ye single point of failure tha, isi problem ko solve karne ke liye DVCS (Git) aaya.

2. Distributed Version Control System

Ab market me entry hoti hai GOAT

The GIT

git is a software/tool/application

git

  1. Daddy of git - Linus Torvalds
  2. Git birthday - April 7, 2005

Isko Linus ne isliye banaya tha kyoki wo Linux dev kar rahe the to ek tool BitKeeper use karte the version control ke liye lekin 2005 me us company walo ne free version free version ka licence revoke kar liya, phir unka tiup tut gaya phir linus ne khud ka ek version control system bana GIT.w

Git me every local PC ke paas Remote repo ki ek clone yani copy hota hai, aur uska complete history bhi hoti hai, app local repo ke saath kaam karte rah sakte hai aur jab man kare to code ko Remote repo pe push kar sakte hai, aur jab aapne code push kiya to dusra pc usko jab chahe tab pull kar sakta hai, aur ab uske pc me bhi bilkul aapke jaisa code dikhega, aur wo bhi offline uspe kaam kar sakta hai aur aap bhi apane pc me offline kaam kar sakte hai.

CVCS vs DVCS

CVCS (Centralized) DVCS (Distributed - Git)
Single central repository Har PC ke paas full repository + history
Internet required for commit/update Internet sirf push/pull ke liye
Commit directly server pe hota hai Commit local machine pe hota hai
Server down → kaam band Server down → local kaam possible
Single point of failure No single point of failure

CDCS

  1. Central server se connect karo
  2. Server se code update (download) karo
  3. Apne local machine pe kaam karo
  4. Changes ko directly server pe commit (upload) karo
  5. Baaki developers server se update karke changes lete hain

DVCS

  1. Remote repository se project clone karo (one time)
  2. Apne local repository pe kaam karo
  3. Changes ko locally commit karo (offline possible)
  4. Jab chaaho tab remote server se connect karo
  5. Apne commits ko push karo
  6. Baaki developers pull karke changes lete hain

Sher (شعر)

Faashle aise bhi honge ye kabhi socha na tha
Faashle aise bhi honge ye kabhi socha na tha
Saamne baitha the mere aur wo mera na tha

Ye kaam dono taraf hua hai
Ye kaam dono taraf hua hai
Use bhi aadat padi hai meri