Skip to content

Refining patches using git

noss edited this page Sep 13, 2010 · 8 revisions

On this page, there should be a guide to how you can use the powerful git rebase -i, git commit --amend, git add -p and perhaps other commands to create a clean set of commits for possible inclusion in Erlang/OTP.

If someone wants to write that text, please go ahead, otherwise I will do it in some point in the future (time permitting).

Amending to previous git commit

If you forgot to add a file to the previous commit, or similar mistakes then git commit --amend can help you.

Amend will not create a new commit on top of HEAD, but instead open the last commit, change it and replace it with the new amended commit. This means that you should never amend to a published commit.

Select chunks to add to index

Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.

This effectively runs add —interactive, but bypasses the initial command menu and directly jumps to the patch subcommand. See “Interactive mode” for details.

Interactive mode in git rebase

Interactive rebase allow you to clean up your commit history by:

  • removing commits
  • squashing commits (like git commit --amend)
  • open up commits for editing

See interactive mode for details.

Clone this wiki locally