Stacked diffs

Tier: Core, Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated Status: Experiment

In the GitLab CLI, stacked diffs are a way of creating small changes that build upon each other to ultimately deliver a feature. Each stack is separate, so you can keep building your feature in one stack while previous parts of the stack receive reviews and updates.

The base command for this feature in the CLI is stack, which you then extend with other commands.

To learn more, see: Stacked Diffs in the CLI overview.

This feature is an experiment. We’d love to hear your feedback in issue 7473.

Create a stacked diff

To do create a stacked diff in the GitLab CLI:

  1. In your terminal window, create a new stack with glab stack create, and give your stack a name.
  2. Make your first set of changes.
  3. To save your first set of changes, enter glab stack save, then a commit message.
  4. Continue creating changes, saving them with glab stack save. Each time you save a stack, glab creates a new branch.
  5. To push your changes up to GitLab, enter glab stack sync. GitLab creates a merge request for each stack.

Commands that build upon glab stack

Use these sub-commands with glab stack:

Add changes to a diff in a stack

To return to a specific point in the stack to add more changes to it:

  1. In your terminal window, use the glab stack move command. glab displays a list of stacks.
  2. Select the stack you want to edit, and make your changes.
  3. When you’re ready to save your changes, use the glab stack amend command.
  4. Optional. Change the description of the stack, if desired.
  5. Run glab stack sync to push your changes back up to GitLab.

When you sync an existing stack, GitLab:

  • Updates the existing stack with your new changes.
  • Rebases the other merge requests in the stack to bring in your latest changes.