gx parent prints the parent branch of the current branch and exits. It is designed for use in shell scripts and pipelines — it outputs only the branch name with no decoration.
Usage
Behavior
- If the current branch is in the stack, prints the stack parent
- If the current branch is not in the stack, prints the HEAD branch (main/master)
- If you are on trunk, exits with code 1 (no output)
- If not in a git repo, exits with code 1 (no output)
Examples
Composability
gx parent is designed for shell pipelines and scripting:
Details
Details
- Output is a single line with just the branch name, no color codes or prefix
- When the branch is in the stack config, the recorded parent is used
- When the branch is not in the stack, the HEAD branch is returned as a sensible default
- On trunk, there is no parent, so the command exits with code 1 and no output