Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Note: You should <strong>not change commits that have been pushed</strong> to another repo in any way <em>unless you know the <a href="https://stackoverflow.com/a/2715147/761771">consequences</a></em>.</p> <p><code>git log --oneline -4</code></p> <pre><code>D commit_message_for_D C commit_message_for_C B commit_message_for_B A commit_message_for_A </code></pre> <p><code>git rebase --interactive</code></p> <pre><code>pick D commit_message_for_D pick C commit_message_for_C pick B commit_message_for_B pick A commit_message_for_A </code></pre> <p>Type <code>i</code> (Put VIM in insert mode)</p> <p>Change the list to look like this (You don't have to remove or include the commit message). <em>Do not misspell <code>squash</code>!</em>:</p> <pre><code>pick C commit_message_for_C pick B commit_message_for_B pick A commit_message_for_A squash D </code></pre> <p>Type <kbd>Esc</kbd> then <code>ZZ</code> (Save and exit VIM)</p> <pre><code># This is a combination of 2 commits. # The first commit's message is: commit_message_for_D # This is the 2nd commit message: commit_message_for_A </code></pre> <p>Type <code>i</code></p> <p>Change the text to what you want the new commit message to look like. I recommend this be a description of the changes in commit <code>A</code> and <code>D</code>:</p> <pre><code>new_commit_message_for_A_and_D </code></pre> <p>Type <kbd>Esc</kbd> then <code>ZZ</code></p> <p><code>git log --oneline -4</code></p> <pre><code>E new_commit_message_for_A_and_D C commit_message_for_C B commit_message_for_B </code></pre> <p><code>git show E</code></p> <pre><code>(You should see a diff showing a combination of changes from A and D) </code></pre> <p>You have now created a new commit <code>E</code>. Commits <code>A</code> and <code>D</code> are no longer in your history but are not gone. You can still recover them at this point and for a while by <code>git rebase --hard D</code> (<em><code>git rebase --hard</code> will destroy any local changes!</em>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload