A custom patch holds lines that you take out of commits. You collect the lines first. Then you choose what stage does with them.
Use a custom patch when one commit contains two changes and only one of them belongs on this branch.
Take a whole file
Section titled “Take a whole file”- Press
4to focus the commits panel. - Press
enteron a commit. stage shows the files of that commit. - Press
spaceon a file.
space takes the whole file.A full dot marks a file that is in the patch. An empty dot marks a file that is not.
Take some lines
Section titled “Take some lines”- Press
enteron a file. stage shows the lines of that file. - Press
vto start a selection. - Press
jorkto extend the selection. - Press
space.
One patch can hold whole files and parts of files at the same time.
The patch stays while you move
Section titled “The patch stays while you move”Press esc to leave the file list. The patch is kept, and the footer says so.
The commits panel shows the patch beside its commit.
You can collect from more than one commit into the same patch. Move to another
commit, press enter, and take more files or more lines.
Choose what to do with it
Section titled “Choose what to do with it”Press ctrl+p to open the patch options.
These options are always available:
| Option | Result |
|---|---|
| reset the custom patch | The patch becomes empty. The commits keep their lines. |
| apply to worktree | The lines are added to the working tree. |
| apply in reverse | The lines are removed from the working tree. |
| copy patch to clipboard | The patch text goes to the clipboard. |
Options that need a clean tree
Section titled “Options that need a clean tree”The options that rewrite history are hidden while the working tree has changes:
| Option | Result |
|---|---|
| remove from commit | The lines leave the source commit. |
| move to the index | The lines leave the commit and enter the index. |
| move to a new commit after | A new commit holds the lines. |
| move to a new commit before | A new commit holds the lines, before the source. |
| move to another commit | The lines move to a commit you pick. |
If you want these options, commit or stash your changes first. stage hides them instead of offering a command that refuses.
When it stops
Section titled “When it stops”The options that rewrite history run as a rebase. A rebase can stop on a conflict, like any other rebase. Read Conflicts for the keys that continue it.
Coming from lazygit
Section titled “Coming from lazygit”stage copies the custom patch of lazygit, and the keys of lazygit. One behavior is different. lazygit shows the history options on a dirty tree, and it stashes around the move-to-index command. stage hides them until the tree is clean.