sds/overcommit · error · Overcommit::Exceptions::HookCleanupFailed

Unable to restore working tree after #{hook_script_name} hoo

Error message

Unable to restore working tree after #{hook_script_name} hooks run:
STDOUT:#{result.stdout}
STDERR:#{result.stderr}

What it means

Error "Unable to restore working tree after #{hook_script_name} hooks run: STDOUT:#{result.stdout} STDERR:#{result.stderr}" thrown in sds/overcommit.

Source

Thrown at lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb:137

                "\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
        end

        # Hard-resetting a staged submodule removal results in the index being
        # reset but the submodule being restored as an empty directory. This empty
        # directory prevents us from stashing on a subsequent run if a hook fails.
        #
        # Work around this by removing these empty submodule directories as there
        # doesn't appear any reason to keep them around.
        removed_submodules.each do |submodule|
          FileUtils.rmdir(submodule.path)
        end
      end

      # Applies the stash to the working tree to restore the user's state.
      def restore_working_tree
        result = Overcommit::Utils.execute(%w[git stash pop --index])
        unless result.success?
          raise Overcommit::Exceptions::HookCleanupFailed,
                "Unable to restore working tree after #{hook_script_name} hooks run:" \
                "\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
        end
      end
    end
  end
end

View on GitHub (pinned to fee0cd74b2)

Solutions

  1. Read the STDOUT/STDERR shown for the failing `git stash pop` command; your unstaged changes are still in the overcommit stash.
  2. Run `git stash list` and `git stash pop` manually to recover the unstaged changes.
  3. Resolve conflicts or file locks that prevented the automatic restore, then rerun the hook.

When it happens

Trigger: Thrown at lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb:137 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sds/overcommit@fee0cd74b2 (2026-08-23). Data as JSON: /api/errors/65492fd7a15248d4. Report an issue: GitHub.