Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save terry-heinel/d0f99b6e653906cde6dc241a01823b27 to your computer and use it in GitHub Desktop.

Select an option

Save terry-heinel/d0f99b6e653906cde6dc241a01823b27 to your computer and use it in GitHub Desktop.

Revisions

  1. @n00neimp0rtant n00neimp0rtant revised this gist Apr 11, 2014. 1 changed file with 5 additions and 9 deletions.
    14 changes: 5 additions & 9 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,16 @@
    ## within current branch, squashes all commits that are ahead of master down into one
    ## useful if you merged with upstream in the middle of your commits (rebase could get very ugly if this is the case)

    ## commit any working changes on branch "mybranchname", then...
    git checkout master
    git checkout -b mybranchname_temp
    git merge --squash mybranchname
    git commit -am "Message describing all squashed commits"
    git branch -m mybranchname bmybranchname_unsquashed
    git branch -m mybranchname mybranchname_unsquashed
    git branch -m mybranchname

    ## optional, not recommended if you want to keep the unsquashed history around for a bit longer
    git branch -D mybranchname_unsquashed

    ## if squashing already-pushed commits...
    git push --force




    git push --force
  2. @n00neimp0rtant n00neimp0rtant created this gist Mar 12, 2014.
    20 changes: 20 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    ## within current branch, squashes all commits that are ahead of master down into one
    ## useful if you merged with upstream in the middle of your commits (rebase could get very ugly if this is the case)

    ## commit any working changes on branch "mybranchname", then...
    git checkout master
    git checkout -b mybranchname_temp
    git merge --squash mybranchname
    git commit -am "Message describing all squashed commits"
    git branch -m mybranchname bmybranchname_unsquashed
    git branch -m mybranchname

    ## optional, not recommended if you want to keep the unsquashed history around for a bit longer
    git branch -D mybranchname_unsquashed

    ## if squashing already-pushed commits...
    git push --force