OT: Squashing Git commits AFTER pushing them

BACK STORY: I’m working on the rubygems.org site. So far, all I’ve done is fill in the missing details on setting up the project. (The only two files I’ve changed are config/database.yml.example and CONTRIBUTING.md.) I forked the project, made changes, pushed them, and submitted a pull request. You can see the pull request at https://github.com/rubygems/rubygems.org/pull/690 .

I was told that I need to combine my multiple commits into one. So I used the “git rebase” command, but there’s one more step that I’m missing. I’m told that I merged in the master branch but didn’t rebase/squash the commits.

When I enter “git log”, the output starts with:

Check the number of commits in your PR and do the following:

$ git reset --soft HEAD~<number_of_commits_in_pr>

$ git commit -m “”

$ git push --force origin <your_branch>

Your commits should be updated on the pull request also.

Hope this helps.

1 Like

Thanks. This worked. Next time, I’m creating and switching to another branch.