Skip to content

How to split one patch into multiple patches? #113

Answered by patdx
patdx asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, after I wrote this I started thinking about the problem again and started browsing through the source code. I found exactly what I want, the command is:

stg refresh --spill

Additionally, the --spill option resets the topmost patch, emptying the patch while leaving the patch’s changes intact in the worktree.

https://stacked-git.github.io/man/stg-refresh/

So, for example, for my case to move the package.json update to another patch:

stg goto <patch-to-split>
stg refresh --spill
git reset # unstage all files, this seems to work fine?
git add package.json
stg refresh --index --patch <first-patch> # add "package.json" to the first patch instead
stg refresh # put the remaining files i…

Replies: 3 comments 1 reply

Comment options

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

Answer selected by patdx
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants