git_checkout
Switch branches or restore working tree files.
Usage
@git_checkout branch="<name>" [new_branch="<name>"] [file="<path>"]
Examples
@git_checkout branch="develop"- Switch to develop branch@git_checkout new_branch="bugfix/login"- Create new branch@git_checkout file="README.md"- Restore file@git_checkout branch="feature" force=true- Force switch (discard changes)@git_checkout branch="origin/main" track=true- Track and checkout remote branch@git_checkout branch="v1.0.0" detach=true- Checkout commit/tag (detached HEAD)
Parameters
| Parameter | Type | Description |
|---|---|---|
branch |
string | Branch name to checkout |
new_branch |
string | Create and checkout a new branch (-b) |
file |
string | File path to restore from HEAD |
force |
boolean | Force checkout |
track |
boolean | Set up tracking for remote branch |
detach |
boolean | Detached HEAD (checkout commit or tag) |
Notes
- Requires git to be installed and in PATH
- Use
branchfor switching to existing branches or commits- Use
new_branchto create and checkout a new branch (-b)- Use
fileto restore specific files from HEAD- Use
track=trueto set up upstream tracking for remote branches- Use
detach=truewhen checking out commits or tags for detached HEAD- Use
force=trueto discard local changes when switching branches