Summary - Remote
- Git course
- Intermediate
- Lesson 28/82
- 5 min
Combine remote commands to build a multi-remote workflow.
Working with Multiple Remotes
You can add multiple remote repository connections to one Git repository. For example, origin can represent your main GitHub repository, while backup represents a backup repository.
git remote add backup https://github.com/user/backup.git
git remote -vThis allows you to list connections, add new ones, and remove those you no longer use.
Practice Organize Remote Repositories
First add a remote connection named archive. Then remove the unused old-backup connection. Finally, list the remaining remote names. Assume that origin and old-backup connections existed initially.
Starter code
# archive bağlantısını ekle
# Eski bağlantıyı kaldır
# Kalan bağlantıları listeleSample solution
git remote add archive https://github.com/user/archive.git
git remote remove old-backup
git remoteExpected output
archive origin
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does having origin and backup connections in one repository mean?
- The local repository is connected to two different remote repositories. Correct answer
- The two remote repositories have been merged automatically.
- The local repository contains two different commits.
- There are two separate branches in the local repository.
Explanation: Each remote name represents a different connection. The same local repository can have both origin and backup connections.
2 Create a New Backup Connection
git remote add ____ https://github.com/user/archive.git
git remote add archive https://github.com/user/archive.git
Explanation: When adding a new connection, specify the remote name first and then its URL.
3 Combine Remote Repository Operations
| Term | Meaning |
|---|---|
git remote |
Lists connection names |
git remote add |
Adds a new connection |
git remote remove |
Removes a connection |
origin |
Main remote name |