Как посмотреть удаленные репозитории в Git
GIT позволяет работать с несколькими удаленными репозиториями. Для просмотра списка удаленных репозиториев, которые сконфигурированы в данный момент для данного локального репозитория, используется команда:
git remote -v
Ключ -v означает verbose и используется, чтобы выводить подробную информацию.
Вывод команды выглядит следующим образом:
origin git@server:pingvin/project.git (fetch) origin git@server:pingvin/project.git (push) upstream git@server2:tux/project.git (fetch) upstream git@server2:tux/project.git (push)
Для каждого удаленного репозитория выводится по 2 строки. Каждая из этих двух строк содержит имя репозитория и URL репозитория, обычно они одинаковы (но необязательно).
Имя репозитория может быть произвольным, например, origin, vasya, upstream, backup, gitlab. Удаленный репозиторий с именем origin создается автоматически, когда выполняется команда git clone.
В скобках указываются флаги (fetch) и (push) . Данные флаги показывают, какой репозиторий будет использоваться при выполнении команд git fetch и git push, соответственно. Можно установить для них разные URL, тогда git fetch будет выполняться с одного адреса, а git push будет производится на другой адрес.
Выполнение git pull эквивалентно последовательному выполнению команд git fetch и git merge, поэтому для git pull используется репозиторий, помеченный флагом (fetch) .
Смотрите также:
- Как изменить файлы в старом коммите (не последнем)
- Как добавить все файлы в коммит, кроме одного
- Как создать ветку из предыдущего коммита
- Команда Git stash. Как прятать изменения в Git
- Как показать файлы, которые будут добавлены в текущий коммит
- Команда Git diff. Как сравнивать изменения в Git
- Как изменить дату коммита
- Как установить Git
- Как добавить файлы в последний коммит
- Как создать новый репозиторий
- Опубликовано: 04.12.2018
Просмотр удалённых репозиториев

Для того чтобы просмотреть список настроенных удалённых репозиториев, вы можете перейти в перспективу Git и в панели Репозитории Git раскрыть структуру своего репозитория.

Если вы клонировали репозиторий, то увидите как минимум origin — имя по умолчанию для исходного репозитория.
Если вы раскроете эту ветку дальше, вы увидите адреса для чтения и записи, привязанные к репозиторию.

Если у вас больше одного удалённого репозитория, вы увидите их все. Это может быть в случае, когда ваш репозиторий настроен на работу с несколькими удалёнными репозиториями разных пользователей. В этом случае вы можете легко получить изменения от любого из этих пользователей, а может быть даже и отправить им свои изменения.
При указании адреса удалённого репозитория Git может использовать большое количество различных протоколов (подробнее об этом будет рассказано далее).

Совет: Дополнительно об удалённых репозиториях вы можете прочитать в документации EGIT на английском языке.
Как узнать адрес origin репозитория в git?
Есть склонированный репозиторий с git, какой командой можно узнать его origin адрес? Т.е адрес, с которого он будет синхронизироваться (fetch и push)?
короткая ссылка на этот вопрос: close
спросил 10 лет назад
1 ответ
origin адрес репозитория:
git remote -v
Эта команда покажет все имена репозиториев, где вы можете делать fetch/push.
$ git remote -v origin ssh://git@stash.domain.com:7999/bng/backend.git (fetch) origin ssh://git@stash.domain.com:7999/bng/backend.git (push) upstream git@bitbucket.org:jekaby/backend.git (fetch) upstream git@bitbucket.org:jekaby/backend.git (push)
Управление удаленными репозиториями
Узнайте, как работать с локальными репозиториями на компьютере и удаленными репозиториями, размещенными в GitHub.
Platform navigation
Adding a remote repository
To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at.
The git remote add command takes two arguments:
- A remote name, for example, origin
- A remote URL, for example, https://github.com/OWNER/REPOSITORY.git
$ git remote add origin https://github.com/OWNER/REPOSITORY.git # Set a new remote $ git remote -v # Verify new remote > origin https://github.com/OWNER/REPOSITORY.git (fetch) > origin https://github.com/OWNER/REPOSITORY.git (push)
For more information on which URL to use, see «About remote repositories.»
Troubleshooting: Remote origin already exists
This error means you’ve tried to add a remote with a name that already exists in your local repository.
$ git remote add origin https://github.com/octocat/Spoon-Knife.git > fatal: remote origin already exists.
To fix this, you can:
- Use a different name for the new remote.
- Rename the existing remote repository before you add the new remote. For more information, see «Renaming a remote repository» below.
- Delete the existing remote repository before you add the new remote. For more information, see «Removing a remote repository» below.
Changing a remote repository’s URL
The git remote set-url command changes an existing remote repository URL.
Tip: For information on the difference between HTTPS and SSH URLs, see «About remote repositories.»
The git remote set-url command takes two arguments:
- An existing remote name. For example, origin or upstream are two common choices.
- A new URL for the remote. For example:
- If you’re updating to use HTTPS, your URL might look like:
https://github.com/OWNER/REPOSITORY.git- If you’re updating to use SSH, your URL might look like:
git@github.com:OWNER/REPOSITORY.gitSwitching remote URLs from SSH to HTTPS
- Open Terminal Terminal Git Bash .
- Change the current working directory to your local project.
- List your existing remotes in order to get the name of the remote you want to change.
$ git remote -v > origin git@github.com:OWNER/REPOSITORY.git (fetch) > origin git@github.com:OWNER/REPOSITORY.git (push)git remote set-url origin https://github.com/OWNER/REPOSITORY.git$ git remote -v # Verify new remote URL > origin https://github.com/OWNER/REPOSITORY.git (fetch) > origin https://github.com/OWNER/REPOSITORY.git (push)The next time you git fetch , git pull , or git push to the remote repository, you’ll be asked for your GitHub username and password. When Git prompts you for your password, enter your personal access token. Alternatively, you can use a credential helper like Git Credential Manager. Password-based authentication for Git has been removed in favor of more secure authentication methods. For more information, see «Managing your personal access tokens.»
You can use a credential helper so Git will remember your GitHub username and personal access token every time it talks to GitHub.
Switching remote URLs from HTTPS to SSH
- Open Terminal Terminal Git Bash .
- Change the current working directory to your local project.
- List your existing remotes in order to get the name of the remote you want to change.
$ git remote -v > origin https://github.com/OWNER/REPOSITORY.git (fetch) > origin https://github.com/OWNER/REPOSITORY.git (push)git remote set-url origin git@github.com:OWNER/REPOSITORY.git$ git remote -v # Verify new remote URL > origin git@github.com:OWNER/REPOSITORY.git (fetch) > origin git@github.com:OWNER/REPOSITORY.git (push)Troubleshooting: No such remote ‘[name]’
This error means that the remote you tried to change doesn’t exist:
$ git remote set-url sofake https://github.com/octocat/Spoon-Knife > fatal: No such remote 'sofake'Check that you’ve correctly typed the remote name.
Renaming a remote repository
Use the git remote rename command to rename an existing remote.
The git remote rename command takes two arguments:
- An existing remote name, for example, origin
- A new name for the remote, for example, destination
Example of renaming a remote repository
These examples assume you’re cloning using HTTPS, which is recommended.
$ git remote -v # View existing remotes > origin https://github.com/OWNER/REPOSITORY.git (fetch) > origin https://github.com/OWNER/REPOSITORY.git (push) $ git remote rename origin destination # Change remote name from 'origin' to 'destination' $ git remote -v # Verify remote's new name > destination https://github.com/OWNER/REPOSITORY.git (fetch) > destination https://github.com/OWNER/REPOSITORY.git (push)Troubleshooting: Could not rename config section ‘remote.[old name]’ to ‘remote.[new name]’
This error means that the old remote name you typed doesn’t exist.
You can check which remotes currently exist with the git remote -v command:
$ git remote -v # View existing remotes > origin https://github.com/OWNER/REPOSITORY.git (fetch) > origin https://github.com/OWNER/REPOSITORY.git (push)Troubleshooting: Remote [new name] already exists
This error means that the remote name you want to use already exists. To solve this, either use a different remote name, or rename the original remote.
Removing a remote repository
Use the git remote rm command to remove a remote URL from your repository.
The git remote rm command takes one argument:
- A remote name, for example, destination
Removing the remote URL from your repository only unlinks the local and remote repositories. It does not delete the remote repository.
Example of removing a remote repository
These examples assume you’re cloning using HTTPS, which is recommended.
$ git remote -v # View current remotes > origin https://github.com/OWNER/REPOSITORY.git (fetch) > origin https://github.com/OWNER/REPOSITORY.git (push) > destination https://github.com/FORKER/REPOSITORY.git (fetch) > destination https://github.com/FORKER/REPOSITORY.git (push) $ git remote rm destination # Remove remote $ git remote -v # Verify it's gone > origin https://github.com/OWNER/REPOSITORY.git (fetch) > origin https://github.com/OWNER/REPOSITORY.git (push)Note: git remote rm does not delete the remote repository from the server. It simply removes the remote and its references from your local repository.
Troubleshooting: Could not remove config section ‘remote.[name]’
This error means that the remote you tried to delete doesn’t exist:
$ git remote rm sofake > error: Could not remove config section 'remote.sofake'Check that you’ve correctly typed the remote name.
Further reading