What instructions to give for squashing PRs from the CLI?

While we will use GitHub's Squash and Merge button for PRs, that doesn't meant everyone will want to use it; some people just prefer using a CLI. That means we need to come up with a set of instructions on how to take a GitHub PR and perform a squash commit manually at the CLI (committing a patch from bugs.python.org is simply since there's no squashing to do). Anyone have that set of commands handy?

On Thu, Oct 06, 2016 at 07:43:21PM +0000, Brett Cannon <brett@snarky.ca> wrote:
While we will use GitHub's Squash and Merge button for PRs, that doesn't meant everyone will want to use it; some people just prefer using a CLI. That means we need to come up with a set of instructions on how to take a GitHub PR and perform a squash commit manually at the CLI (committing a patch from bugs.python.org is simply since there's no squashing to do). Anyone have that set of commands handy?
It's something like:: $ git fetch github pull/$ID/head:$BRANCHNAME $ git checkout master $ git merge --squash $BRANCHNAME $ git branch -d $BRANCHNAME Oleg. -- Oleg Broytman http://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN.

I usually go with the visual version which goes like this: 1. git rebase -i HEAD~2 (where 2 means here 2 previous commits) 2. now in editor you can pick which commit can be squashed to which (all nicely described) 3. mark 2nd commit, which will be squashed to previous with squash, write changes and exit 4. now you can tweak the log message (both are shown), write changes and exit You're left with just single commit. On Fri, Oct 7, 2016 at 1:35 PM, Oleg Broytman <phd@phdru.name> wrote:
On Thu, Oct 06, 2016 at 07:43:21PM +0000, Brett Cannon <brett@snarky.ca> wrote:
While we will use GitHub's Squash and Merge button for PRs, that doesn't meant everyone will want to use it; some people just prefer using a CLI. That means we need to come up with a set of instructions on how to take a GitHub PR and perform a squash commit manually at the CLI (committing a patch from bugs.python.org is simply since there's no squashing to do). Anyone have that set of commands handy?
It's something like::
$ git fetch github pull/$ID/head:$BRANCHNAME $ git checkout master $ git merge --squash $BRANCHNAME $ git branch -d $BRANCHNAME
Oleg. -- Oleg Broytman http://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN. _______________________________________________ core-workflow mailing list core-workflow@python.org https://mail.python.org/mailman/listinfo/core-workflow This list is governed by the PSF Code of Conduct: https://www.python.org/psf/codeofconduct

On Oct 07, 2016, at 01:35 PM, Oleg Broytman wrote:
$ git fetch github pull/$ID/head:$BRANCHNAME $ git checkout master $ git merge --squash $BRANCHNAME $ git branch -d $BRANCHNAME
This works well, and is generally the instructions that GitLab provides for local CLI merges. A few things to note.
$ git fetch github pull/$ID/head:$BRANCHNAME ^^^^^^ This is the remote name, so it will usually be 'origin' but it can be anything (i.e. it's up to the local user).
$ git fetch github pull/$ID/head:$BRANCHNAME ^^^^^^^^^^^^ This isn't strictly necessary. If not given, use FETCH_HEAD. And if you want to do some things with the branch before you merge it to master (e.g. add NEWS, uncommit code changes to make sure that the tests prove a fix works, etc.) then you can:
$ git co -b $BRANCHNAME FETCH_HEAD Of course, $BRANCHNAME can be anything you want. Cheers, -Barry
participants (4)
-
Barry Warsaw
-
Brett Cannon
-
Maciej Szulik
-
Oleg Broytman