The reset command performs a hard reset of your git repository while carefully preserving all files in the .codegen directory. This is useful for undoing codemod changes while keeping your codemod implementations intact.

Usage

codegen reset

What it Does

When you run codegen reset, it:

  1. Backs up all files in .codegen directory, preserving their content and staged/unstaged status
  2. Performs a hard reset (git reset --hard HEAD) on the repository
  3. Restores all .codegen files to their previous state, including their git staging status
  4. Removes untracked files (except those in .codegen)

This is more sophisticated than git checkout . as it:

  • Preserves both staged and unstaged changes in .codegen
  • Handles deleted files correctly
  • Removes untracked files (like git clean) while protecting .codegen

Examples

Reset after testing a codemod:

# Run your codemod
codegen run organize-imports

# If the changes aren't what you wanted
codegen reset  # Reverts changes but keeps your codemod implementation

This command performs a hard reset and removes untracked files. Make sure you have committed any changes you want to keep outside of .codegen.

Was this page helpful?