HomeCreate a layer-by-layer PR from an accumulated branch GitHub CLI extension

Technology is

Create a layer-by-layer PR from an accumulated branch GitHub CLI extension

Editing illustration representing the accumulated software branches in order from the lower branches in abstract lines and nodes
AI generated image

The GitHub CLI extension “gh stack” was released to create PR for each accumulated branch and set the layer right below as a base.

Stack structure that inherits the immediate branch.

The “gh stack” released by GitHub is a GitHub CLI extension that manages accumulated branches and PR. The stack is represented as an ordered list of branches, each of which inherits the next branches.

The lowest layer of the branch is based on the luggage branch, and the more you move upwards, the more you move away from the luggage.This structure allows you to keep the big changes as a multi-layer dependent.

Build the branch order with init and add.

The init command initializes the local stack to the current repository.If you specify a branch name, it incorporates the existing branch into the stack and creates a new branch for the name that does not exist.

The base will be the default branch of the repository unless changed in the base. In the top layer of the stack, the add command creates a branch from the current HEAD and checks out by adding that branch as a new top layer.

Connect PR for each branch to a single stack

When the submit command is executed, one for each branch that forms the stack.PRThey are created and associated with each other as a single stack on GitHub.PRThe relationship between dependencies.

The bottom of each PR is set to the bottom of the branch. This setting shows the differences added in the layer rather than the cumulative changes in the entire stack on the review screen.

Keep the entire chain in a localized state.

The configuration of the stack and the order of the branches are saved in the JSON file in the .git/gh-stack. This file is not committed to the repository and tracks the relationship between the branches locally.

The rebase command obtains updates from the origin and rebases each layer of the stack in a chain. Movements between layers also follow the same order, up indicating the direction of leaving the trunk and down indicating the direction of approaching the trunk.