Skip to content

How to split stack of patches in 2 (or more) branches? #498

Answered by jpgrayson
tino asked this question in Q&A
Discussion options

You must be logged in to vote

The following script is helpful for me. Here's the workflow:

  • Develop patches on main stack.
  • Eventually, a subset of those patches will be ready to become a PR/MR. To appease GitHub/GitLab's workflow, I need those particular patches to be on their own branch.
  • In main stack, apply the patches to be carved onto their own branch.
  • Run this script, providing the new branch name as the argument.
#!/usr/bin/env bash

set -euo pipefail

top=$(stg top)
newbranch=${1:-${top/-/'/'}}
curbranch=$(stg branch)

set -x

stg branch -C "$newbranch"
stg delete -U
stg branch "$curbranch"
stg delete "..$top"
stg rebase "$newbranch"
stg branch "$newbranch"

After the script runs, a new branch exists with only …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tino
Comment options

Answer selected by tino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants