Andrea
Andrea

Reputation: 795

Squash GitHub commit online

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?

Upvotes: 5

Views: 8168

Answers (1)

Chris
Chris

Reputation: 136967

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.

Upvotes: 1

Related Questions