2

I have made my first contribute to a project on GitHub. I have selected the file to edit, created a pull request, and made my edits. Then I noticed a mistake, selected the file again, and made my corrections. I always worked online, no command line. Now a contributor od the project asked me to squash my two commits. The question is: how?

Andrea
  • 675
  • 1
  • 13
  • 34
  • https://stackoverflow.com/questions/14534397/squash-all-my-commits-into-one-for-github-pull-request – vidit Nov 27 '15 at 17:24
  • I doubt that you can. GitHub's online editing facilities are pretty basic, and aren't anything close to a complete Git client. You will probably have to do this offline. – ChrisGPT was on strike Nov 27 '15 at 19:26
  • Ok I will try from the command line. But how can I "move" from the online editor to the command line? – Andrea Nov 28 '15 at 07:07

1 Answers1

1

But how can I "move" from the online editor to the command line?

See Modifying an active pull request locally in GitHub's documentation:

  1. In any repository's right sidebar, click Pull Requests.
  2. In the "Pull Requests" list, click the pull request you'd like to merge.
  3. At the bottom of the pull request, click command line. Follow the sequence of steps to bring down the proposed pull request.

Then modify the branch locally.

In this case you'll want to squash the commits using git rebase --interactive <commit-before-yours>. Choose to pick your first commit and squash your second one.

Finally, push it back to the existing PR branch on GitHub. In this case you'll have to use --force since you're replacing your old commits with a new one.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257