Git
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.
Exercise 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.
Show example solution
# Uzak depoyu tanımla
git remote add origin https://github.com/ada/project.git
# Ana dalı gönder
git push origin main
Test yourself
-
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
Show answer
A local repository containing project history — In the distributed model, each developer has their own local repository, which stores the project history.
-
Connect the local repository to a remote
git remote add origin ____
Show answer
git remote add origin https://github.com/ada/project.git
-
Distributed Git structure
- Local repository
- Repository on the computer
- Remote repository
- Shared remote repository
- git push
- Sends commits to the remote
- git pull
- Brings remote changes locally
Next lesson: Summary - What is Git?