-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
additional merge options for git ship
#2441
Comments
Thanks for bringing this up, I agree that the ship behavior should be configurable. Are you using |
I just found Git Town today. With the current behavior, I'd never use |
I used to do what you describe, but big PR's never got a good review. A 10 line PR will get constructive comments; big ones don't. And it was a giant PITA to keep reshuffling my commits into logical atomic commits. Telling my reviewers to review commit-by-commit sometimes helped, but frankly the hub reviewing apparatus isn't set up great for that. Now with git-town, what would have previously been a commit is now a PR. Instead of 5 commits in a PR, I have 5 "nested feature branches" and 5 PR's. My PR's are small and atomic and get proper reviews. |
These days most developers use Git Town to create and sync feature branches and create proposals, merge using the GitHub UI or a merge queue, and then run |
git ship
git ship
git ship
Some context from other issues
Originally posted by @kevgo in #2324 (comment)
Originally posted by @kevgo in #673 (comment)
Request
There should be a configuration option for
git ship
that determines strategy (i.e. choose between rebase, merge commit, and squash).A few related ideas for further enhancement:
git ship
strategy if the line limit is exceededThese changes would ensure quality commit history without over-reliance on squash merges, which, IMHO, are bad the majority of the time and indicative of antipatterns.
Background
It seems that Git Town design assumes that commit history will be cluttered with WIP commits and that squash commits are the right way to go. However, I consider pushing WIP commits to be an anti-pattern - I would reject any PR that contains any WIP commits unless it's a good candidate for squashing (atomic and < ~150 lines changed. Atomic as in "no unrelated changes in the same commit").
If I saw a PR with a bunch of WIP commits (or a single massive commit containing a bunch of unrelated changes), I would tell the submitter to revise their git history and resubmit. Commit history should be useful - that means you have meaningful commit messages and that your commits have some sort of logical grouping. A good commit history should let you review a PR one commit at a time in the event that a branch has a significant number of changes (incidentally, this is basically the gerrit code review workflow, and it is something I VERY much miss using)
Squash commits are a bad idea most of the time, because they intermingle unrelated changes and make it harder to review code. If you have a commit about updating documentation and another commit about fixing totally unrelated bugs, but they are otherwise grouped in a single PR because there's some logical reason for it, then squashing means that you have a bugfix combined with your doc updates and can no longer consider them individually. Worse, if your PR has a large number of lines changed, a squash merge means you might have a PR with 1000+ lines changed and no way to make it more atomic by looking at commits individually.
An additional problem with squash commits is that if you need to revert a change, you can't revert just one small commit, you have to revert the entire squashed history and then manually pick through and discard changes you don't want to revert.
TL;DR, I would reject any PR that contained WIP commits over ~150 lines and/or had a single commit with a ton of unrelated changes. By and large, I agree with the guidelines that are described at Git Commit Best Practices
What is my typical workflow?
The way I tend to work looks something like this:
As a more concrete example, this is roughly how I tend to open new repos:
wip project setup
commits for setting up the basic project stuff (package.json, tsconfig.json, linting, hooks, etc)wip update config
This approach also minimizes churn - most of my final commits tend to be additive, as opposed to the same line of code changing multiple times. So it is generally possible to review one commit at a time more quickly than the flattened PR, since related changes are grouped.
Click me for a concrete mock example of the above
I start with a commit history like
then rearrange to
and finally squash related commits:
The text was updated successfully, but these errors were encountered: