Skip to content

Rewriting Commits with GitUp

Pierre-Olivier Latour edited this page Mar 2, 2016 · 2 revisions

Overview

One of GitUp most useful feature is commit rewriting. You can use to fix a typo in an old commit, add comments to your source code, apply code review requested changes, etc...

To rewrite a commit, simply select it in the Map view and choose "Rewrite" in the contextual menu or press W on the keyboard. Note that your repository must be a clean state before starting a rewrite operations, so stash first any pending changes.

Rewriting in Action

Once commit rewriting has started, your repository has been rolled back to the commit to rewrite, and the files in the working directory are as they were in that commit.

From this point on, edit the files in the working directory as you normally would e.g. with TextMate, Xcode, etc... The file list and diff area will reflect live what the rewritten commit would be.

When you are done editing the files, just click "Continue..." and provide an updated commit message if needed before confirming the rewrite.

WARNING: While rewriting a commit, avoid doing any Git operations with the Git command line or any other Git client as you may confuse GitUp.

Keyboard Shortcuts

  • While in the rewriting view:
  • Arrow up & Arrow down to jump to a different file
  • O to open the selected file with its default editor
  • D to view the diffs for the selected file(s) with the external diff tool
  • Esc to cancel commit rewriting
  • Return to continue and enter the message view
  • While in the message view:
  • Return to insert a newline in the commit message
  • Opt-Return to save the rewritten commit
  • Esc to return to the rewriting view

Tips

  • If you botched your commit rewriting, just undo with Cmd-Z or from the "Edit" menu
  • It's possible to only discard some lines from a file instead of the entire file by selecting these lines before clicking on the discard button
  • You can view the diff for a specific file with the external diff tool using the action menu (gear icon)
  • You can resize the panes by putting your mouse over a divider and dragging

More Information

  • See this topic to learn more about the diff area