Skip to main content

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
  • 9
    do you have to pick the top one and squash the rest? You should edit your answer to explain how to use the interactive rebase editor in more detail Commented Sep 7, 2018 at 17:35
  • 5
    Yes, leave pick in line 1. If you choose squash or fixup for the commit on line 1, git will show a message saying "error: cannot 'fixup' without a previous commit". Then it will give you the option to fix it: "You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'." or you can just abort and start over: "Or you can abort the rebase with 'git rebase --abort'.".
    – br3nt
    Commented Sep 10, 2018 at 3:27
  • 4
    @Timo, correct. Oldest at the top, newest at the bottom. That's why you need to pick the first line. And when you choose squash or fixup on a line, it will put the changes into the commit on the line above.
    – br3nt
    Commented Nov 8, 2020 at 23:05
  • 2
    This feels like the best answer when you know that you want to squash a certain amount of commits or at least see the commits you can squash by entering some arbitrary number. Generally, I use this .
    – Staghouse
    Commented Jan 25, 2021 at 20:07
  • 1
    @Andy Thanks! I've updated the answer, and also included a link to the relevant Git docs.
    – br3nt
    Commented Feb 27 at 1:05