CodeBlanks Logo Icon CodeBlanks

Distributed model

Learn the advantages of Git's distributed nature.

Git's distributed model

Git is a distributed version control system. In this model, each developer can have a local repository containing the project's history. You can create commits, inspect history, and work with branches without being continuously connected to a central server.

Developer A          Developer B
 Local Repository    Local Repository
       \                /
        Remote Repository

A remote repository provides a shared location for exchanging changes between team members.

Local and remote repositories

A local repository is the Git repository stored on your computer where you work. A remote repository is hosted by a service such as GitHub and allows you to share work with other developers. git push sends local commits to the remote repository, while git pull brings remote changes into your local work.

git push origin main
git pull origin main

You can perform most local operations without an internet connection; communication with the remote repository requires a connection.

Practice Use the local and remote repository workflow

Add https://github.com/ada/project.git as a remote repository named origin. Then push the main branch to the remote repository.

Starter code

terminal
# Uzak depoyu tanımla

# Ana dalı gönder

Sample solution

terminal
# Uzak depoyu tanımla
git remote add origin https://github.com/ada/project.git

# Ana dalı gönder
git push origin main

Expected output

To https://github.com/ada/project.git
 * [new branch]      main -> main

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does a developer have in Git's distributed model?

  • Only a list of files on a remote server
  • A mandatory internet connection for every operation
  • Only a read-only copy of the project
  • A local repository containing project history Correct answer

Explanation: In the distributed model, each developer has their own local repository, which stores the project history.

2 Connect the local repository to a remote

Question
git remote add origin ____
Answer
git remote add origin https://github.com/ada/project.git

Explanation: The remote repository address is registered under the name origin to define a connection for the local repository.

3 Distributed Git structure

Term Meaning
Local repository Repository on the computer
Remote repository Shared remote repository
git push Sends commits to the remote
git pull Brings remote changes locally

All lessons in Beginner