Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Using Soft Reset Instead of Rebase to Squash GIT History</strong></p> <p>I think the <strong>length</strong> of VonC's answers speaks volumes -- literally -- about how complicated <code>git rebase</code> is. This is my extension of <a href="https://stackoverflow.com/questions/2320772/redoing-commit-history-in-git-without-rebase/2320803#2320803">another answer to a question of mine</a>.</p> <ol> <li>You have a branch <code>ticket-201</code> that you branched from <code>master</code>. You want to pretend that all the commits from <code>ticket-201</code> never happened, but that you did all the work in one shot.</li> <li>Soft reset to the branch point using <code>git reset --soft hash</code> where <code>hash</code> should be a commit hash that is in <code>ticket-201</code>'s log.</li> <li>Commit your changes using add then commit. Now the branch history will only have the first commit and the new one with the new stuff.</li> </ol> <p><strong>Making Up Histories From Arbitrary Commits in Different Branches</strong></p> <p>Using resets you can rewrite the history as you see fit, though your edits will lose the charm of having the right timestamp. Assuming you don't care about that (the times/dates on your files will be enough, perhaps?), or if you want to fiddle with the commits as you go, you can follow these steps:</p> <ol> <li>Checkout a new branch at <code>commit0</code> (pretend that's a hash): <code>git checkout -b new-history commit0</code></li> <li>Now you can get the files from <code>commit5</code>: <code>git reset --hard commit5</code></li> <li>Switch back to your index point: <code>git reset --soft commit0</code></li> <li>Commit and this will be the second commit in the branch.</li> </ol> <p>This idea is simple, effective and flexible.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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