close
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.

Required fields*

Required fields*

How do I squash my last N commits together?

How do I squash my last N commits together into one commit?

Answer*

Draft saved
Draft discarded
Cancel
12
  • 7
    Interesting, but I'd much rather type the squashed commit message myself, as a descriptive summary of my multiple commits, than have it auto-entered for me. So I'd rather specify git squash -m "New summary." and have N determined automatically as the number of unpushed commits. Commented Apr 22, 2014 at 18:50
  • 2
    @A-B-B, This sounds like a separate question. (I don't think it's exactly what the OP was asking; I've never felt a need for it in my git squash workflow.) Commented Apr 23, 2014 at 22:29
  • 4
    This is pretty sweet. Personally I'd like a version that uses the commit message from the first of the squashed-together commits. Would be good for things like whitespace tweaks. Commented Jul 10, 2014 at 1:40
  • @funroll Agreed. Just dropping the last commit msg is a super common need for me. We should be able to devise that... Commented Sep 26, 2014 at 15:52
  • 4
    @A-B-B you can use git commit --amend to further change the message, but this alias lets you have a good start on what should be in the commit message. Commented Jul 14, 2016 at 15:59