Stacked diffs
- Released in v1.42.0 of the GitLab CLI as an 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.
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:
- In your terminal window, create a new stack with
glab stack create
, and give your stack a name. - Make your first set of changes.
- To save your first set of changes, enter
glab stack save
, then a commit message. - Continue creating changes, saving them with
glab stack save
. Each time you save a stack,glab
creates a new branch. - 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:
- In your terminal window, use the
glab stack move
command.glab
displays a list of stacks. - Select the stack you want to edit, and make your changes.
- When you’re ready to save your changes, use the
glab stack amend
command. - Optional. Change the description of the stack, if desired.
- 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.