Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

12
  • 3
    Added in 1.7.12: github.com/git/git/blob/master/Documentation/RelNotes/…
    – serbaut
    Commented Mar 5, 2013 at 20:45
  • 91
    This answer is ok, but if you're interactively rebasing more than, say, 20 commits, the interactive rebase will probably be way too slow and unwieldy. You're probably going to have a hard time trying to squash hundreds or thousands of commits. I would go with a soft or mixed reset to the root commit, then recommit, in that case.
    – user456814
    Commented Jun 11, 2014 at 2:55
  • 47
    If you have many commits it's hard to change 'pick' to 'squash' manually. Use :%s/pick/squash/g in VIM command line to do this faster.
    – eilas
    Commented Aug 4, 2017 at 14:17
  • 6
    this works find, but I had to do a forced push. be careful! git push -f
    – philshem
    Commented Oct 25, 2019 at 6:42
  • 4
    @eilas No need for the g. You only want to replace the first instance of the word pick on each line. Even better is :%s/^pick/squash/.
    – user137369
    Commented Apr 13, 2023 at 19:05