Skip to content

Quick Start

This guide walks you through the most common operations: cloning, staging, committing, and pushing.

import Gitty
let repo = try await Repository.clone(
from: URL(string: "https://github.com/user/repo")!,
to: URL(fileURLWithPath: "/path/to/local"),
credentials: .token("ghp_yourtoken")
)
let repo = try Repository.open(at: URL(fileURLWithPath: "/path/to/repo"))
let author = Signature(name: "Alice", email: "alice@example.com")
try repo.stageAll()
let commit = try repo.commit(message: "Initial commit", author: author)
print(commit.oid.string)
let entries = try repo.status()
for entry in entries {
print(entry.path, entry.status)
}
try await repo.remotes.push(
to: "origin",
branch: "main",
credentials: .token("ghp_yourtoken")
)