Skip to content
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

Add section on stacking pull requests to Pull Requests guide #51

Open
mcmire opened this issue Oct 5, 2023 · 1 comment
Open

Add section on stacking pull requests to Pull Requests guide #51

mcmire opened this issue Oct 5, 2023 · 1 comment

Comments

@mcmire
Copy link
Contributor

mcmire commented Oct 5, 2023

If you have a set of changes that you need to split up into separate stages, and some of those stages are dependent on each other, you'll need to create PRs that depend on each other. There's some specific advice around creating stacked pull requests. Specifically,

  • keep all PRs in the stack except the first in draft (because of the next point)
  • you never want to merge a PR that's not the first in the stack into another that's also not the first — when the first PR is merged, you need to rebase all other PRs
@MajorLift
Copy link
Contributor

As each PR is merged, the remaining PRs need to be rebased.

  • It helps if merges with main are minimized in all of the PRs (especially the first one). Each merge potentially adds redundant commits in the remaining PRs and it can be difficult to sort through the resulting commit history containing duplicates of parent PR commit ranges that need to be removed, interspersed with commits from the current PR that need to be preserved.
  • If using vim for rebasing, the command :<start-line>, <end-line>s/pick/drop is useful for discarding ranges of parent PR commits.
  • In the interest of ensuring that the reviewed PR state is not corrupted, after rebasing, do not push the new local branch state immediately. Instead, merge the remote branch into the local branch before running git push --force.
    • Use this shell command: git merge --squash <remote-repo>/$(git branch --show-current).
    • In case of merge conflicts (meaning something in the rebase process mutated the local branch's state), accept incoming for all. The remote branch is the source of truth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants