Distributed model
- Git course
- Beginner
- Lesson 3/80
- 4 min
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 RepositoryA 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 mainYou 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
# Uzak depoyu tanımla
# Ana dalı gönderSample solution
# Uzak depoyu tanımla
git remote add origin https://github.com/ada/project.git
# Ana dalı gönder
git push origin mainExpected 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
git remote add origin ____
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 |