Remotes, Fetch & Push
Remote operations are available via repo.remotes. Network operations (fetch, push) are async.
List remotes
Section titled “List remotes”let remotes = try repo.remotes.list()for remote in remotes { print(remote.name, remote.url)}Add a remote
Section titled “Add a remote”try repo.remotes.add(name: "origin", url: "https://github.com/user/repo")Remove a remote
Section titled “Remove a remote”try repo.remotes.remove(named: "origin")Rename a remote
Section titled “Rename a remote”try repo.remotes.rename("old-name", to: "new-name")try await repo.remotes.fetch( remote: "origin", credentials: .token("ghp_yourtoken"))With progress
Section titled “With progress”try await repo.remotes.fetch( remote: "origin", credentials: .token("ghp_yourtoken"), progress: { p in print("Objects: \(p.receivedObjects)/\(p.totalObjects)") })try await repo.remotes.push( to: "origin", branch: "main", credentials: .token("ghp_yourtoken"))See Credentials for all authentication options.