Skip to content

Instantly share code, notes, and snippets.

@baverman
Created February 25, 2026 19:17
Show Gist options
  • Select an option

  • Save baverman/c2d2391e8a5fc1f5aa103fc798124585 to your computer and use it in GitHub Desktop.

Select an option

Save baverman/c2d2391e8a5fc1f5aa103fc798124585 to your computer and use it in GitHub Desktop.
stg helpers
#!/bin/bash
set -e
suffix="${1:?'Fixup suffix is required, i.e "fix"'}"
top="$(stg top)"
base="${top%--*}"
if [ -z "$base" ]; then
echo "stg-fixup expects an applied patch"
fi
default_msg="$(git show "$(stg id "$base")" -s --pretty=format:%s)"
msg="${2:-"$default_msg"}"
stg new -m "$msg" "${base}--${suffix}"
#!/bin/bash
set -e
top=$(stg top)
base="${top%--*}"
if [ -z "$base" ]; then
echo "stg-update expects an applied patch"
fi
git push -f ${1:-origin} HEAD:$base
@baverman
Copy link
Author

Usage

It's assumed you already have current patch with associated PR, patch name corresponds to PR name.

To add a fixup patch which should be added as a separate commit to the PR:

stg-fixup fix

"fix" is any short name describing change to differ it in you local stg patches.

To push both patches:

stg-update

You could do stg refresh to fix patch and do stg-update to sync changes.

To make another commit in the PR invoke stg-fixup another-fix and then stg-update again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment