gx init creates the .git/gx/stack.json configuration file that tracks branch relationships for stacking. This is optional — most stacking commands auto-initialize when needed.
Usage
Flags
| Flag | Description |
|---|---|
--trunk | Explicitly set the trunk branch (default: auto-detected HEAD branch) |
--force | Re-initialize, updating the trunk branch while preserving existing branch relationships |
Example
Re-initialize
Use--force to change the trunk branch without losing tracked relationships:
Auto-initialization
You do not need to rungx init before using stacking commands. When you run gx stack for the first time, gx auto-creates the config with the detected HEAD branch as trunk.
Running gx init when already initialized shows the current state:
Config location
Config location
The stack config is stored at
.git/gx/stack.json inside the repo’s git directory. It is not tracked by git and does not appear in your working tree. This means it is local to each clone — collaborators each have their own stack config.