Git

Show the status of a repository

Show the changed and untracked files of a repository.

git.status "/home/user/app"
/home/user/app
git status --short

Show the staged changes

Show the differences of the staged changes with their statistics.

git.diff "/home/user/app" staged: true stat: true
files

Show the history of a file

Show the last ten commits that changed a file.

git.log "/home/user/app" count: 10 path: ["src/main.go"]
commit

Show one commit

Show the changes of one revision.

git.show "/home/user/app" "HEAD"
HEAD

Find who changed a line

Show the author of each line of a range of a file.

git.blame "/home/user/app/src/main.go" lines: 10..20
main.go

Stage files and commit

Commit selected files with a message.

git.commit "/home/user/app" message: "fix: parser" paths: ["/home/user/app/a.go"]
fix: parser
git add a.go && git commit -m "fix: parser"

Commit with a trailer

Add a trailer line to the message of a commit.

git.commit "/home/user/app" message: "fix: parser" trailers: ["Co-Authored-By: Name <name@example.com>"] staged: true
fix: parser

Create and switch to a branch

Create a branch and switch to it.

git.switch "/home/user/app" branch: "feature/x" create: true
feature/x

Save a checkpoint before a risky change

Record the state of the working tree so that it can be restored.

git.checkpoint "/home/user/app" action: create label: "before refactoring"
before refactoring

Restore a checkpoint

Restore the working tree from a checkpoint.

git.checkpoint "/home/user/app" action: restore checkpoint_id: "before refactoring"
before refactoring

Stash the changes

Stash the changes, including untracked files.

git.stash "/home/user/app" action: push include_untracked: true
stash

Review the changes before a commit

Check the working tree for conflict markers, large files and secrets.

git.review "/home/user/app" scope: working checks: ["conflict_markers", "secrets"]
finding

Fetch from the remote

Fetch the branches and prune the deleted ones.

git.fetch "/home/user/app" prune: true
origin

Push a branch

Push a branch and set its upstream.

git.push "/home/user/app" branch: "feature/x" set_upstream: true
feature/x

Clone a repository

Clone a repository into a directory.

git.clone "https://example.com/team/app.git" "/home/user/src/app" depth: 1
/home/user/src/app

Show the untracked files

Show every untracked file, not only the collapsed directories, with the numbers of changed lines.

git.status "/home/user/app" untracked: all stat: true
/home/user/app
git status --short --untracked-files=all

Compare two revisions

Show the changes between two revisions of a path.

git.diff "/home/user/app" from: "v1.0.0" to: "HEAD" path: ["src"] stat: true
files
git diff --stat v1.0.0 HEAD -- src

Show a word-level diff

Show the changes of the working tree by words and ignore changes of whitespace.

git.diff "/home/user/app" word_diff: true ignore_whitespace: true
hunk

Show the commits of an author

Show the commits of one author since a date.

git.log "/home/user/app" author: "ann" since: "2026-10-01T00:00:00Z" count: 50
commit
git log --author=ann --since=2026-10-01 -n 50

Find the commit that introduced a text

Find the commits that added or removed a given text.

git.log "/home/user/app" pickaxe: "retryLimit" path: ["src"]
commit
git log -S retryLimit -- src

Group the commits by type

Group the last 100 commits by their conventional type.

git.log "/home/user/app" count: 100 group_by: type
group

Show a file in a revision

Show the changes of one file in a revision with its statistics.

git.show "/home/user/app" "HEAD~2" file: "/home/user/app/src/main.go" stat: true
main.go
git show --stat HEAD~2 -- src/main.go

List the branches

List the local branches of a repository.

git.branch "/home/user/app"
main
git branch

Create a branch from a revision

Create a branch that starts at a tag and keep the current branch.

git.branch "/home/user/app" create: "hotfix/1.0.1" from: "v1.0.0"
hotfix/1.0.1
git branch hotfix/1.0.1 v1.0.0

Delete a merged branch

Delete a branch; the repository keeps it in the trash so that it can be restored.

git.branch "/home/user/app" delete: "feature/x" trash: true
feature/x

Stage the changes of a path

Stage the changes of a directory.

git.stage "/home/user/app" action: add paths: ["/home/user/app/src"]
src
git add src

Unstage a file

Remove a file from the index and keep its changes.

git.stage "/home/user/app" action: unstage paths: ["/home/user/app/a.go"]
a.go
git restore --staged a.go

Restore a file from a revision

Restore a file to its state in the last commit and save a checkpoint first.

git.restore "/home/user/app" paths: ["/home/user/app/a.go"] source: "HEAD" checkpoint: true
a.go
git restore --source=HEAD a.go

Amend the last commit

Replace the message of the last commit.

git.commit "/home/user/app" message: "fix: parser error" amend: true
fix: parser error
git commit --amend -m "fix: parser error"

Create an annotated tag

Create an annotated tag for a release.

git.tag "/home/user/app" name: "v1.2.0" message: "release 1.2.0"
v1.2.0
git tag -a v1.2.0 -m "release 1.2.0"

Merge a branch

Merge a branch and refuse a merge that is not a fast-forward.

git.merge "/home/user/app" branch: "feature/x" fast_forward: only
feature/x

Abort a merge

Abort a merge that stopped on a conflict.

git.merge "/home/user/app" action: abort
effect
git merge --abort

Rebase onto a branch

Rebase the current branch onto the main branch.

git.rebase "/home/user/app" onto: "main"
main

Pull with a rebase

Fetch the upstream branch and rebase the local commits onto it.

git.pull "/home/user/app" mode: rebase
origin
git pull --rebase

Apply and drop a stash

Apply the newest stash and remove it from the stash list.

git.stash "/home/user/app" action: pop
stash

Add a worktree for a branch

Check out a branch in a second directory.

git.worktree "/home/user/app" action: add path: "/home/user/app-hotfix" branch: "hotfix/1.0.1"
/home/user/app-hotfix
git worktree add /home/user/app-hotfix hotfix/1.0.1

Push the tags

Push a branch together with the tags.

git.push "/home/user/app" branch: "main" tags: true
main

Push with a lease

Replace a remote branch only when it has not changed since it was fetched.

git.push "/home/user/app" branch: "feature/x" force: lease
feature/x
git push --force-with-lease origin feature/x

Source file on GitHub: docs/cookbook/git.md