The order in which we should merge or stacked PRs is completely subjective. It depends on how you want the merge commits to look on master. Squashing and rebasing both overwrites Git’s history (albeit in different ways), removing the overlap that deemed the two branches continuous. Git knew to do so because it saw a commit with the same metadata on the two branches. If you recall, changing the base from master to ts-setup shaved off the common commit between ts-setup and migrate-components. Git tracks changes through commits by commit hashes. This restriction does not apply to the last PR on a given PR chain. The only restriction you have on merging while working with stacked PRs is that you cannot “squash and merge” or “rebase and merge.” You must merge directly. The worst-case scenario is someone merging a PR, pulling master, not finding the changes, and getting confused, which begs the question, how do you merge stacked PRs? How to merge stacked pull request Squash, merge, or rebase? Explore Tauri, a new framework for building binaries.Discover how to animate your React app with AnimXYZ.Switch between multiple versions of Node.Use React's useEffect to optimize your application's performance.Learn how LogRocket's Galileo cuts through the noise to proactively resolve issues in your app.Don't miss a moment with The Replay, a curated newsletter from LogRocket.Make sure to clearly state that a PR is stacked on top of another. Notice that while master is set as the base of our PR, the changes from ts-setup (“Setup TypeScript” commit) are present, and our commit count is at two.Ĭhanging the base branch to ts-setup removes overlapping commits, bringing our commit count to just one. This effectively turns ts-setup and migrate-components into stacked branches ready to become stacked PRs. $ mv components/Button.jsx components/Button.tsx $ git checkout -b migrate-components # checkout from ts-setup Then, checkout the second branch from the first. In your GitHub repository, you’ll be prompted to create a pull request from ts-setup: $ git checkout -b ts-setup # checkout from master To stack two PRs, checkout the first branch from your base master (or develop) and push your changes. Stacking two branches is easier to handle than working on the same branch. This is especially handy when two people are trying to collaborate on the same feature. If page migration is dependent on components migration, you can stack the branches even further. This means that if a change occurs in ts-setup, migrate-pages would have to merge or rebase ts-setup. This would allow the two branches, migrate-pages and migrate-components, to share the TypeScript configuration in a master-like relationship with the ts-setup branch. The TypeScript setup (dependency installation, tsconfig.json, etc.) would have to be shared between the two of you, either by eagerly committing the setup to the master (or develop) branch, or by stacking your PRs on top of a ts-setup feature branch. The other situation where stacked PRs really shine is when you want to use a particular change in two or more branches.įor instance, imagine wanting to migrate a codebase to TypeScript where you rewrite the pages in TS while your teammate rewrites the components.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |