Skip to content

Credentials

Gitty’s Credentials enum covers all common authentication methods. Pass credentials to clone, fetch, and push.

Section titled “Personal Access Token (recommended for GitHub/GitLab)”
let creds = Credentials.token("ghp_yourpersonalaccesstoken")
let creds = Credentials.usernamePassword(
username: "alice",
password: "hunter2"
)

Delegates to the system SSH agent (ssh-agent). The agent must be running and have the key loaded.

let creds = Credentials.sshAgent

Falls back to the system Git credential helper (macOS Keychain, etc.):

let creds = Credentials.default
try await repo.remotes.fetch(
remote: "origin",
credentials: .token("ghp_yourtoken")
)
let repo = try await Repository.clone(
from: URL(string: "https://github.com/user/private")!,
to: localURL,
credentials: .usernamePassword(username: "alice", password: "secret")
)