<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Benedict Pregler on Medium]]></title>
        <description><![CDATA[Stories by Benedict Pregler on Medium]]></description>
        <link>https://medium.com/@benedict.pregler?source=rss-420f91fd544a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SQSNwe3hiaEaU7sV0hl4vg.jpeg</url>
            <title>Stories by Benedict Pregler on Medium</title>
            <link>https://medium.com/@benedict.pregler?source=rss-420f91fd544a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 23:34:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@benedict.pregler/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Manage stacked PRs with SPR]]></title>
            <link>https://medium.com/@benedict.pregler/manage-stacked-prs-with-spr-295de2744e00?source=rss-420f91fd544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/295de2744e00</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Benedict Pregler]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 13:39:46 GMT</pubDate>
            <atom:updated>2024-04-19T13:39:46.053Z</atom:updated>
            <content:encoded><![CDATA[<p>Breaking down complex code changes into smaller, interdependent PRs is the key to an efficient PR review process. Stacked PRs provide just that, making the reviewing process more manageable for the reviewer and allowing you to continue working without waiting for reviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/0*sZaQjyW3UmsmD20T.png" /><figcaption>Source: <a href="https://twitter.com/iamdevloper/status/397664295875805184">https://twitter.com/iamdevloper/status/397664295875805184</a></figcaption></figure><h3>What are stacked PRs?</h3><p>Stacked PRs help developers manage big code changes by breaking them down into smaller changes. Instead of submitting one huge change for review, which can be hard to check and approve, developers submit a series of smaller changes.<br>Each small change relies on the one before it, making it easier for others to review each part. This method keeps the review process simple and quick, and the PR author is unblocked from pending reviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQYB7JKOnhanSvn8OvOs1Q.png" /></figure><p>Managing stacked PRs manually is cumbersome and error-prone, which can create a big mess out of your stacked PRs. For example, when a PR in the middle of a stacked PR needs a change, you would need to add the change and then manually rebase all the following PRs.<br>Fortunately, the developer community has kept us from fending for ourselves. Tools have been crafted to simplify and streamline handling stacked PRs.</p><p>Among these tools, SPR (Stacked Pull Requests on GitHub) stands out for its simplicity and effectiveness. Developed by Eitan Joffe, SPR is a minimalist command-line interface (CLI) tool designed to manage stacked PRs efficiently without the clutter of unnecessary features.</p><h3>Setting up SPR</h3><p>SPR can be found on GitHub (<a href="https://github.com/ejoffe/spr">https://github.com/ejoffe/spr</a>). Installation instructions are straightforward.</p><p><strong>Configuration</strong><br>Before we can start using SPR in the CLI, we need to set up a personal Github Token so SPR can access the Github API and create PRs for us, show their status, or even merge PRs from the command line.<br>There are three options to set up the personal access token so SPR can pick it up:</p><p>1. Create a <a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens">personal access token</a> and add it as an environment variable GITHUB_TOKEN<em>.</em></p><p>2. Install the official Github CLI (<a href="https://cli.github.com/">https://cli.github.com</a>) and login via:</p><pre>$ gh auth login — insecure-storage</pre><p>3. Alternatively, configure a token manually in ~/.config/hub:github.com:</p><pre>— user: &lt;your username&gt;<br>  oauth_token: &lt;your token&gt;<br>  protocol: https</pre><p>When the script runs for the first time, two .yml configuration files are created. You can easily modify them to match your needs. You can find further information in the <a href="https://github.com/ejoffe/spr?tab=readme-ov-file#configuration">Readme.md</a>.</p><h3>Using SPR</h3><p>By calling git spr, we can quickly check if SPR is installed and see all the available commands.<br>Using SPR also means understanding stacked PRs and how SPR creates them. We create a chain of stacked PRs by creating a new branch. For example, yourName/featureX, and commit to this branch, as we typically do with Git.<br>When we are ready to create and publish PRs, we use the command git spr update. This command accomplishes several tasks: it generates PRs from every commit made to the feature branch, rebases your feature branch onto the latest main branch commit, and updates any already open PRs. For example, if you have three commits on your feature branch, SPR will create three separate PRs, each corresponding to one of the commits. This process encourages you to make smaller, well-defined commits that include all necessary changes to meet potential PR CI requirements.</p><p>To better understand your stack SPR will also add the stack as a description to the PR so your colleagues can understand where they are in the stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1XZ-bSTHnCBdXn1Og0sJQ.png" /><figcaption>PR description created by SPR</figcaption></figure><p>With git spr status, you can always check the status of your PRs from the command line, whether they are mergeable, and what is missing (e.g., GitHub checks passing, pull request approval, no merge conflicts, stack check).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aYO--qts792vIUZB3y9Z3g.png" /><figcaption>Example output after calling git spr status</figcaption></figure><p>When you want to work on two features simultaneously, you can maintain two feature branches, for example, yourName/feature1 and yourName/feature2. Commit to these branches as usual and use SPR to create PRs from every commit, allowing you to progress on one feature without blocking the other.</p><h3>Change a commit/PR</h3><p>As shown in the first image, your peers can conduct a more thorough PR review when you create smaller PRs, which also means you may receive more change requests for your PRs. This involves modifying commits in your feature branch. To make these changes, you can make the required adjustments, execute git amend, and then run git spr update to allow SPR to update the PRs. Remember, SPR will create PRs from your commits—nothing more, nothing less.</p><h3>Merge with SPR</h3><p>Once we receive the necessary reviews and the CI approves our PR, we can merge it. By using git spr merge, we can merge the first stacked PR, and SPR will also accommodate a potential GitHub merge queue.</p><p>When no merge queue is in place and rebase merging is permitted, SPR will automatically merge all PRs that are eligible for merging. If these conditions aren’t met, SPR will merge only the first PR. Afterward, you can use git spr update to rebase the subsequent PRs on the main branch that now includes the merged PR. You&#39;ll then need to wait for the CI checks to pass again before merging the next PR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yFZb8UtuEzdxiVgbJpC3Gw.png" /><figcaption>Status with merge queue indicator</figcaption></figure><p>After a successful merge with a merge queue, we can run git spr update to update the remaining stacked PRs automatically.</p><h3>Conclusion</h3><p>Stacked PRs are a powerful technique to keep your PRs small and the PR reviews efficient. Thanks to SPR, we can easily create stacked PRs and keep them up-to-date without manually rebasing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=295de2744e00" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>