Skip to content

Instantly share code, notes, and snippets.

@longtimeago
Last active April 1, 2024 20:44
Show Gist options
  • Star 47 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save longtimeago/f7055aa4c3bba8a62197 to your computer and use it in GitHub Desktop.
Save longtimeago/f7055aa4c3bba8a62197 to your computer and use it in GitHub Desktop.
How to squash commits in a GitHub pull request

How to squash commits in a GitHub pull request

o you've contributed some code to an open source project, say, Rails. And they'd like you to squash all of the commits in your pull request. But you're not a git wizard; how do you make this happen?

Normally, you'd do something like this. I'm assuming upstream is a git remote that is pointing at the official project repository, and that your changes are in your 'omgpull' branch:

$ git fetch upstream
$ git checkout omgpull 
$ git rebase -i upstream/master

< choose squash for all of your commits, except the first one >
< Edit the commit message to make sense, and describe all your changes >

$ git push origin omgpull -f

@dimyme
Copy link

dimyme commented Sep 21, 2018

omg what nonsensical "doc"

@sp1ff
Copy link

sp1ff commented Mar 16, 2019

omg what nonsensical "doc"

I dunno, I found it helpful.

@rjl6789
Copy link

rjl6789 commented Jun 18, 2019

I also found it helpful.... googled how to squash commits before a pull request. This popped up. Followed the information/instructions. Job done! Thanks!
Rob

@FingerLiu
Copy link

It works!

@rafaelcapucho
Copy link

Wow, straightforward and it works! Thx

@Nirmalyasen
Copy link

Works and easy to follow!

@andrewm4894
Copy link

Thats twice now it saved me! Have a feeling i'll be back :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment