|
| 1 | +--- |
| 2 | +name: git-workspace |
| 3 | +description: How to work with branches in a git-workspace repository |
| 4 | +--- |
| 5 | + |
| 6 | +## What is git-workspace |
| 7 | + |
| 8 | +A git plugin that manages isolated development environments on top of git worktrees. Each branch gets its own fully configured environment — dependencies installed, configuration files applied, environment variables loaded, lifecycle hooks executed. All commands are invoked as `git workspace <command>`. |
| 9 | + |
| 10 | +## When to use this skill |
| 11 | + |
| 12 | +Use `git workspace` commands when any of these apply: |
| 13 | +- The user wants to work on a feature, hotfix, or any other branch |
| 14 | +- The user mentions workspaces, environments, or spinning up a branch context |
| 15 | + |
| 16 | +Before using any `git workspace` command, confirm you are in a workspace: |
| 17 | + |
| 18 | +```bash |
| 19 | +git workspace root # exit 0 → workspace, exit 1 → not a workspace |
| 20 | +``` |
| 21 | + |
| 22 | +If exit 1, fall back to regular git commands. Standard git operations (commit, push, pull, rebase, merge) always use plain `git` regardless. |
| 23 | + |
| 24 | +## Activating a branch |
| 25 | + |
| 26 | +```bash |
| 27 | +WORKTREE=$(git workspace up <branch> --detached -o) |
| 28 | +``` |
| 29 | + |
| 30 | +- `--detached` skips interactive hooks not meant for agents |
| 31 | +- `-o` prints the worktree path to stdout and suppresses all other output |
| 32 | +- Use `$WORKTREE` as the working directory for all subsequent operations on that branch |
| 33 | + |
| 34 | +`up` installs dependencies, applies configuration files and symlinks, loads environment variables, and runs any other setup the human has defined. Do not replicate this with raw `git worktree` commands — you will produce an incomplete environment. |
| 35 | + |
| 36 | +## Resetting a branch |
| 37 | + |
| 38 | +```bash |
| 39 | +git workspace reset <branch> |
| 40 | +``` |
| 41 | + |
| 42 | +Reapplies configuration, symlinks, and setup hooks after a pull or merge so the environment reflects the updated branch state. Do not call after `git workspace up` — `up` already performs this setup. |
| 43 | + |
| 44 | +## Typical workflow |
| 45 | + |
| 46 | +``` |
| 47 | +1. git workspace root # confirm workspace |
| 48 | +2. git workspace up <branch> --detached -o # activate branch |
| 49 | +3. git pull / commit / push # standard git inside $WORKTREE |
| 50 | +4. git workspace reset <branch> # after pull/merge, reapply environment |
| 51 | +``` |
| 52 | + |
| 53 | +## Constraints |
| 54 | + |
| 55 | +- Always run `git workspace root` before any `git workspace` command |
| 56 | +- Always pass `--detached` and `-o` to `git workspace up` |
| 57 | +- Never call `git worktree` directly inside a workspace |
0 commit comments