Skip to main content

hjk recreate

Recreate the container for an instance while preserving the worktree.

Synopsis

hjk recreate <branch> [flags]

Description

Recreates the container for an instance. This command:

  1. Stops and deletes the existing container
  2. Creates a new container with the same worktree

Useful when the container environment is corrupted or needs a fresh state. The worktree (and all git-tracked and untracked files) is preserved.

Arguments

ArgumentDescription
branchGit branch name of the instance to recreate (required)

Flags

FlagTypeDefaultDescription
--basestringUse a different base image for the new container

Examples

# Recreate with same image
hjk recreate feat/auth

# Recreate with new image
hjk recreate feat/auth --base my-registry.io/new-image:v2

Use Cases

  • Corrupted container: When a container's environment becomes corrupted or unstable
  • Image update: When you want to use a newer version of the base image
  • Clean slate: When you want to reset the container state without losing code changes
  • Configuration change: When you need to apply new container configuration

Behavior

  • All running sessions in the container are terminated
  • The container is deleted and a new one is created
  • The git worktree directory is preserved and remounted
  • A new instance ID is generated for the new container

See Also

  • hjk stop - Stop without recreating
  • hjk rm - Remove instance entirely
  • hjk run - Create a new session after recreating