btw_tool_git_branch_checkout: Tool: Git Branch Checkout

View source: R/tool-git.R

btw_tool_git_branch_checkoutR Documentation

Tool: Git Branch Checkout

Description

Allows an LLM to switch to a different git branch using gert::git_branch_checkout(), equivalent to ⁠git checkout <branch>⁠ in the terminal.

Usage

btw_tool_git_branch_checkout(branch, force = FALSE, `_intent` = "")

Arguments

branch

Name of branch to check out.

force

Whether to force checkout even with uncommitted changes. Defaults to FALSE.

_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 a confirmation message.

See Also

Other git tools: btw_tool_git_branch_create(), btw_tool_git_branch_list(), btw_tool_git_commit(), 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")

  fs::file_touch("hello.md")

  gert::git_add("hello.md")
  gert::git_commit("Initial commit")

  gert::git_branch_create("feature-1")

  # LLM checks out an existing branch
  res <- btw_tool_git_branch_checkout(branch = "feature-1")

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


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