remote

For git-remote(1).

Overview

Manage git remotes using GitRemoteManager (collection-level) and GitRemoteCmd (per-remote operations).

Examples

List remotes — a freshly cloned repository has its origin:

>>> from libvcs.cmd.git import Git
>>> git = Git(path=example_git_repo.path)
>>> git.remotes.ls()
[<GitRemoteCmd path=... remote_name=origin>]

Add a remote:

>>> from libvcs.cmd.git import Git
>>> git = Git(path=example_git_repo.path)
>>> git.remotes.add(name='upstream', url='https://github.com/org/repo.git')
''

Get a specific remote and operate on it through its Cmd object:

>>> from libvcs.cmd.git import Git
>>> git = Git(path=example_git_repo.path)
>>> origin = git.remotes.get(remote_name='origin')
>>> 'origin' in origin.show()
True
>>> origin.prune()
''
>>> origin.set_url(url='https://example.com/new.git')
''

API Reference

class libvcs.cmd.git.GitRemoteManager
class libvcs.cmd.git.GitRemoteManager

Bases: object

Traverse git remotes with QueryList.

class libvcs.cmd.git.GitRemoteCmd
class libvcs.cmd.git.GitRemoteCmd

Bases: object

Run git commands targeting a specific remote.