btw_tool_git_commit: Tool: Git Commit

View source: R/tool-git.R

btw_tool_git_commitR Documentation

Tool: Git Commit

Description

This tool allows an LLM stage files and create a git commit. This tool uses a combination of gert::git_add() to stage files and gert::git_commit() to commit them, which is equivalent to ⁠git add⁠ and ⁠git commit⁠ in the terminal, respectively.

Usage

btw_tool_git_commit(message, files = NULL, `_intent` = "")

Arguments

message

A commit message describing the changes.

files

Optional character vector of file paths to stage and commit. Use "." to stage all changed files. If NULL, commits currently staged files.

_intent

An optional string describing the intent of the tool use. When the tool is used by an LLM, the model will use this argument to explain why it called the tool.

Value

Returns the commit SHA.

See Also

Other git tools: btw_tool_git_branch_checkout(), btw_tool_git_branch_create(), btw_tool_git_branch_list(), btw_tool_git_diff(), btw_tool_git_log(), btw_tool_git_status()

Examples


withr::with_tempdir({
  gert::git_init()
  gert::git_config_set("user.name", "R Example")
  gert::git_config_set("user.email", "ex@example.com")

  writeLines("hello, world", "hello.md")

  res <- btw_tool_git_commit("Initial commit", files = "hello.md")

  # What the LLM sees
  cat(res@value)
})


btw documentation built on Nov. 5, 2025, 7:45 p.m.