Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

git - Github squash commits from web interface on pull request after review comments?

Let's say I have a commit history with 5 commits. I know that I can rebase my commits locally when making a pull request which will then have them rebased into a single commit.

A common use case for this is:

  • Make local commits, working on feature
  • Squash commits
  • Make Pull Request
  • Receive review comments
  • Update PR appropriately

I can do this locally on my machine and then push my change again (using -f since the rebase makes it out of sync with the remote). This is kind of annoying.

However, this requires that I do a rebase every time I address review comments - is there any way I can do this from the web interface?

Or maybe my workflow is wrong, should I be amending each of my "review comments" commits directly onto the main PR commit?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

You don't have to do any rebase/squashing locally anymore: just push your commit to your PR branch.

The owner of the original repo, if he/she chose to, will squash those commits for you (since March 2016):

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

See "Squash your commits" and the documentation: it does allow for a new workflow, both for you the contributor, and the maintainer of the original repo.

As I comment below: it will be implemented like the merge of a PR is implemented:

  • If it works without conflict, the merge (or here, the merge --squash: see "In git, what is the difference between merge --squash and rebase?") will be created automatically.
  • If there is any conflict, the merge is not created, and the maintainer has the option to reject for now the PR, asking the contributor to do the work of squashing the commits and amending the PR.

This is really like what exists now, except GitHub has added the --squash to their merge command. Nothing more.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...