Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
888 views
in Technique[技术] by (71.8m points)

git - Squash to only one "proper" commit for github pull request

I have a repo on github which someone else (Bob, for the sake of argument) has issued a pull request for. His code's not perfect, so we go through a few rounds of markups. As I understand it, he commits and pushes to his pull-request for each set of marked up changes.

So my repository now looks like this:

master: ---o A (Chowlett
           |
           |
pull-req:  o---o---o---o
               B   C   D (all Bob)

Commit SHAs and msgs are as follows:

A:

123456 Good commit <chowlett>

B:

777ccc Fix the widget bug <bob>

C:

888ddd Review markups <bob>

D:

999eee Further markups <bob>

I'm now happy to accept this pull request; but I'd rather the pre-markup versions weren't in my repo. Can I achieve all of the following; and how?

  • Merge B, C & D into my repo as a single commit
  • Generate the "Merge pull request #99 into ..." commit as well
  • Have github automatically close the pull request
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Note that Bob doesn't have to squash his commits when he is making a GitHub PR.
Since March 2016, you can leave that operation to the maintainer (you) accepting your PR.

See "Squash your commits" and its new documentation

This is a new option which lets you force commit squashing on all pull requests merged via the merge button.

https://help.github.com/assets/images/help/pull_requests/squash-and-merge.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...