![]() are omitted (i.e., a patch already accepted upstream with a different commit message or timestamp will be skipped). Note that any commits in HEAD which introduce the same textual changes as a commit in HEAD. ![]() The commits that were previously saved into the temporary area are then reapplied to the current branch, one by one, in order. above ("Consecutively apply each commit") from the git-rebase docs: This is the right behavior, but how does this work? How does git-rebase know not to reapply commits d9? Before this rebase is applied there are four commits accessible from f3 that aren't accessible from f2, but the rebase only results in two commits being applied to f2. ![]() The next rebase ( git rebase f2) is a different story, though. In Fig 7., git rebase f1 is fairly straightforward - it picks all of f2's commits onto f1. Hard reset the current branch pointer so it points to Ĭonsecutively apply each commit from Step 1 Make a list of all commits that are reachable from HEAD but not from Let's go over everything that git does when you run git rebase : Git-rebase includes a deduplication mechanism to help it avoid picking duplicate commits, but this doesnt work well with conflicted commits. This is good enough in some cases, but there's one glaring issue with this approach - it can't handle conflicts. So far so good! You can use a sequence of rebases like this to keep your stack of PRs in sync during a code review. Note that the use of git-rebase also requires a force push, because we're moving the branch pointers f2 and f3 to entirely new commits. This takes you back to having a linear chain of commits. I find that git concepts are much more easily understood with a visualization than text!Įnable Javascript to use this visualization. Incremental approval: Large, thorny changes can be approved in pieces.įirst, let's go over a visual example of a stack of PRs. Reviewers: Every PR in the stack can potentially be assigned to a different set of reviewers, which can be helpful in a few different contexts - ramping, areas of expertise, or workload. I'll cover all of that in the rest of this post.Īfter having used the stacked PR workflow for a while, the benefits are readily apparent:ĭependencies: Changes that your feature depends on (but are otherwise unrelated) can go in a separate PR. There are a couple of nuances to keep in mind, as well as tooling that can help automate most of the annoying bits away. GitHub (unfortunately) doesn't provide any native support for stacked PRs, but (assuming you can't switch to another tool), managing a stack of PRs isn't too hard to do manually. When it's time to merge, start from the topmost PR (the one that's furthest from master) and merge/rebase every PR in until you merge the entire stack in to master ![]() Repeat until you have a stack of pull requests Here's the basic idea:Ĭreate a pull request from a feature branch (say feature-1) to masterĬreate a second pull request from another feature branch (say feature-2) to feature-1 The only real solution to this problem (that I know of, anyway) is the notion of stacked PRs. You have to put them in a single PR, which can be confusing all around. When a single large PR has well-formed commits, it's fairly easy to review it sequentially, but there are other potential problems.Ĭommits can't be approved individually, so you have to treat the entire PR as being in progress until it's done, even if only a small part is in contention.ĭependent-but-unrelated changes are problematic too. Changes that build on the original either go in the same PR, or have to wait until the PR is merged so a second PR can be created. Every change/feature typically goes in a single PR. I've replaced each one with an image of its final state so the post isn't completely unreadable, but I'd encourage you to allow JS execution to get the full experience.Ĭode review using GitHub pull requests (PRs) is generally pretty decent, but you're going to have trouble with medium-to-large changes, especially when the dependencies involved mean you can't split them up into disparate PRs. This page contains (git commit history) visualizations that won't work without Javascript. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |