Skip to content

[Feature request] Reverse region, hunk, file #1882

@MarkRebane

Description

@MarkRebane

Is your feature request related to a problem? Please describe.

Magit has support for reversing regions, hunks, and files from existing commits. I've often found this feature useful in commit rewriting workflows that involve:

  • reverse several small regions of code that found their way into the wrong commit
  • make a fixup commit that removes the change from an unmerged commit
  • make a fixup commit that re-adds the change to a different unmerged commit

Describe the solution you'd like

I'd like feature parity with Magit to reverse a region, hunk, or file, i.e.

  • show a commit
  • select a region with visual mode (or use the highlighted hunk / file)
  • press 'u' to reverse the change
  • reversing a change should:
    • create a staged change that undoes the region AND
    • create an unstaged change that reapplies the region

Additional context

Note that reversing a region is different to reverting a commit because:

  • the scope of the reverse is smaller
  • the output produces both the staged undo and unstaged redo

Screenshot of the outcome of reversing a visual region in Magit:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions