Bird
Raised Fist0
Gitdevops~10 mins

Distributed vs centralized version control in Git - Visual Side-by-Side Comparison

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Process Flow - Distributed vs centralized version control
Start: Developer wants to save code
Centralized VCS
Commit changes to central server
Other devs pull from central server
Distributed VCS
Commit changes locally
Push changes to shared remote
Other devs pull from shared remote or clone full repo
Shows how centralized VCS relies on one central server for commits and updates, while distributed VCS allows local commits and later syncing with others.
Execution Sample
Git
git init
# Create local repo

git commit -m "First commit"
# Commit locally

git push origin main
# Push to remote

git pull origin main
# Pull updates
Basic git commands showing local commit and syncing with remote repository.
Process Table
StepActionLocationResultNotes
1git initLocal machineLocal repository createdStart local repo, no remote yet
2git commit -m "First commit"Local machineCommit saved locallyChanges recorded only on local repo
3git push origin mainLocal to RemoteChanges sent to remote serverRemote repo updated with local commit
4git pull origin mainLocal from RemoteUpdates fetched and mergedLocal repo synced with remote
5Other dev clones repoOther dev machineFull repo copied locallyDistributed VCS allows full copy
6Other dev commits locallyOther dev machineCommit saved locallyLocal commits independent of remote
7Other dev pushes changesOther dev to RemoteRemote updated with new commitsSyncing changes with others
8Centralized VCS commitDirectly on central serverCommit saved on central serverNo local commits, all on server
9Centralized VCS updateLocal from central serverLatest changes fetchedMust be connected to central server
10Exit--No more steps, process ends
💡 Process ends after syncing commits between local and remote repositories
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5After Step 6After Step 7
Local repositoryNoneInitializedHas commitSynced with remoteCloned full repoHas new local commitSynced with remote
Remote repositoryNoneNoneHas commit from pushSame as local after pullHas full repoSame as beforeUpdated with new commits
Key Moments - 3 Insights
Why can I commit changes without internet in distributed VCS but not in centralized VCS?
In distributed VCS, commits are saved locally first (see Step 2 and Step 6), so internet is not needed. Centralized VCS requires connection to central server for every commit (Step 8).
How does syncing work differently between distributed and centralized VCS?
Distributed VCS syncs by pushing and pulling full commits between local and remote repos (Steps 3,4,7). Centralized VCS always fetches from or commits directly to central server (Steps 8,9).
What happens when another developer clones the repo in distributed VCS?
They get a full copy of the entire repository including history (Step 5), allowing them to work offline and commit locally.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step is the first local commit saved?
AStep 2
BStep 3
CStep 6
DStep 8
💡 Hint
Check the 'Result' column for 'Commit saved locally' in the first few steps.
At which step does the remote repository first get updated with new commits?
AStep 2
BStep 3
CStep 6
DStep 7
💡 Hint
Look for 'Remote updated' or 'Changes sent to remote server' in the 'Result' column.
If a developer has no internet, which action can they still perform?
APush changes to remote
BPull updates from remote
CCommit changes locally
DClone repository
💡 Hint
Refer to Steps 2 and 6 where commits are saved locally without remote interaction.
Concept Snapshot
Distributed VCS lets you commit locally and sync later with others.
Centralized VCS requires a central server for all commits and updates.
Distributed VCS clones full repo; centralized only fetches latest.
Use git commands: init, commit, push, pull to manage distributed repos.
Distributed VCS works offline; centralized needs constant connection.
Full Transcript
This visual execution compares distributed and centralized version control systems using git commands. It shows how distributed VCS allows developers to commit changes locally without internet and later push to a remote repository. Centralized VCS requires all commits to be made directly on a central server, needing constant connection. The execution table traces steps like initializing a repo, committing locally, pushing to remote, and pulling updates. Variable tracking shows the state of local and remote repositories after each step. Key moments clarify common confusions about offline commits and syncing. The quiz tests understanding of when commits happen locally or remotely and what actions require internet. The snapshot summarizes the main differences and typical git commands used.

Practice

(1/5)
1. Which statement best describes distributed version control systems like Git?
easy
A. Changes are only saved on the server, not locally.
B. Each user has a full copy of the repository including history.
C. Users cannot work offline and must always connect to the server.
D. There is only one central server where all files are stored.

Solution

  1. Step 1: Understand distributed version control

    Distributed systems like Git give every user a complete copy of the repository, including all history.
  2. Step 2: Compare with centralized systems

    Centralized systems rely on one main server, unlike distributed ones where users work independently.
  3. Final Answer:

    Each user has a full copy of the repository including history. -> Option B
  4. Quick Check:

    Distributed = full local copy [OK]
Hint: Distributed means full local copy for each user [OK]
Common Mistakes:
  • Confusing distributed with centralized control
  • Thinking users must always connect to server
  • Believing changes are only saved on server
2. Which of the following commands initializes a new Git repository locally?
easy
A. git clone https://example.com/repo.git
B. git commit -m 'start'
C. git push origin main
D. git init

Solution

  1. Step 1: Identify command to create new repo

    The command git init creates a new local Git repository.
  2. Step 2: Understand other commands

    git clone copies an existing repo; git commit saves changes; git push sends changes to remote.
  3. Final Answer:

    git init -> Option D
  4. Quick Check:

    Initialize repo = git init [OK]
Hint: Use git init to start a new local repo [OK]
Common Mistakes:
  • Using git clone to create a new empty repo
  • Confusing commit with init
  • Trying to push before creating repo
3. Given a centralized version control system, what happens if the central server goes offline?
medium
A. Users cannot commit or update until the server is back online.
B. Users can continue working and commit locally without issues.
C. Users automatically get a full copy of the repo to work offline.
D. Users can push changes to a backup server automatically.

Solution

  1. Step 1: Understand centralized system dependency

    Centralized systems depend on the main server for commits and updates.
  2. Step 2: Effect of server downtime

    If the server is offline, users cannot commit or update until it returns.
  3. Final Answer:

    Users cannot commit or update until the server is back online. -> Option A
  4. Quick Check:

    Centralized needs server online [OK]
Hint: Centralized needs server online to commit [OK]
Common Mistakes:
  • Assuming offline commits are possible in centralized systems
  • Thinking users get full repo copies automatically
  • Believing backup servers sync automatically
4. You cloned a Git repository but forgot to fetch the latest changes. Which command fixes this?
medium
A. git fetch origin
B. git clone --update
C. git push origin main
D. git init

Solution

  1. Step 1: Identify command to update local repo

    git fetch origin downloads latest changes from remote without merging.
  2. Step 2: Understand other commands

    git clone --update is invalid; git push sends changes; git init creates new repo.
  3. Final Answer:

    git fetch origin -> Option A
  4. Quick Check:

    Update local repo = git fetch [OK]
Hint: Use git fetch to get latest remote changes [OK]
Common Mistakes:
  • Using git clone again instead of fetch
  • Trying to push before fetching
  • Running git init on existing repo
5. In a distributed version control system like Git, how can multiple users work on the same project without a central server?
hard
A. They cannot work without a central server in distributed systems.
B. They use a single shared folder on a network drive.
C. They share patches and merge changes manually between local repos.
D. They must push all changes to a cloud server immediately.

Solution

  1. Step 1: Understand distributed collaboration

    In distributed systems, users have full repos and can share changes as patches or pull requests.
  2. Step 2: How users share changes without central server

    They exchange patches or pull changes directly between local repositories manually or via other means.
  3. Final Answer:

    They share patches and merge changes manually between local repos. -> Option C
  4. Quick Check:

    Distributed = manual patch sharing possible [OK]
Hint: Distributed allows manual patch sharing without central server [OK]
Common Mistakes:
  • Thinking distributed needs central server always
  • Assuming network shared folder is standard practice
  • Believing immediate cloud push is required