larsks · GitHub

Using the rust branch, I run into this a lot:

  1. stg pop --spill to incorporate some changes into a previous patch
  2. git reset to unstage everything
  3. stg refresh to update the patch after adding some updated files
  4. stg push to return to the next patch in the series

This invariably fails with:

error: Index/worktree dirty

And that's because the stg pop --spill + git reset means that any files in the subsequent patch that aren't included in the current patch are now in the way. Using git checkout, we would see something like this:

error: The following untracked working tree files would be overwritten by checkout:
        cluster-scope/base/core/namespaces/external-secrets-operator/namespace.yaml
Please move or remove them before you switch branches.
Aborting

The solution here is generally git checkout --force, which will replace the indicated files.

It would be great if stg push had the same option, because sometimes cleaning this up is a pain (it would also be nice if stg push were to provide a list of files that are causing the error).

Read the original on github.com ↗