Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When doing <code>git rebase -i</code> there is this interesting bit in the doc:</p> <blockquote> <p>If you want to fold two or more commits into one, replace the command <code>"pick"</code> for the second and subsequent commits with <code>"squash"</code> or <code>"fixup"</code>. If the commits had different authors, the folded commit will be attributed to the author of the first commit. The suggested commit message for the folded commit is the concatenation of the commit messages of the first commit and of those with the <code>"squash"</code> command, but omits the commit messages of commits with the <code>"fixup"</code> command.</p> </blockquote> <ul> <li>If you have an history of <code>A-B-C-D-E-F</code>,</li> <li>and you want to change commits <code>B</code> and <code>D</code> (= 2 commits),</li> </ul> <p>then you can do:</p> <ul> <li><code>git config user.name "Correct new name"</code></li> <li><code>git config user.email "correct@new.email"</code></li> <li>create empty commits (one for each commit): <ul> <li>you need a message for rebase purpose</li> <li><code>git commit --allow-empty -m "empty"</code></li> </ul></li> <li>start the rebase operation <ul> <li><code>git rebase -i B^</code></li> <li><code>B^</code> selects the parent of <code>B</code>.</li> </ul></li> <li>you will want to put one empty commit <strong>before</strong> each commit to modify</li> <li>you will want to change <code>pick</code> to <code>squash</code> for those.</li> </ul> <p>Example of what <code>git rebase -i B^</code> will give you:</p> <pre><code>pick sha-commit-B some message pick sha-commit-C some message pick sha-commit-D some message pick sha-commit-E some message pick sha-commit-F some message # pick sha-commit-empty1 empty # pick sha-commit-empty2 empty </code></pre> <p>change that to:</p> <pre><code># change commit B's author pick sha-commit-empty1 empty squash sha-commit-B some message # leave commit C alone pick sha-commit-C some message # change commit D's author pick sha-commit-empty2 empty squash sha-commit-D some message # leave commit E-F alone pick sha-commit-E some message pick sha-commit-F some message </code></pre> <p>It will prompt you to edit the messages:</p> <pre><code># This is a combination of 2 commits. # The first commit's message is: empty # This is the 2nd commit message: ...some useful commit message there... </code></pre> <p>and you can just remove the first few lines.</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