<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sven Luijten</title>
    <description>The latest articles on DEV Community by Sven Luijten (@svenluijten).</description>
    <link>https://dev.to/svenluijten</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F7787%2F11269635.jpeg</url>
      <title>DEV Community: Sven Luijten</title>
      <link>https://dev.to/svenluijten</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/svenluijten"/>
    <language>en</language>
    <item>
      <title>Open multiple simultaneous pull requests</title>
      <dc:creator>Sven Luijten</dc:creator>
      <pubDate>Fri, 07 Jul 2017 20:49:13 +0000</pubDate>
      <link>https://dev.to/svenluijten/open-multiple-simultaneous-pull-requests</link>
      <guid>https://dev.to/svenluijten/open-multiple-simultaneous-pull-requests</guid>
      <description>

&lt;p&gt;Forking repositories is at the core of contributing to open source, and everyone does it just a little bit differently. So let's take a look at how I used to handle multiple pull requests on the same repository, the problems it presented and the solution to those problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Say I want to create 2 pull requests to solve 2 seperate issues on the repository &lt;code&gt;octocat/test-project&lt;/code&gt;. A lot of people would create their first just fine:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fork the repository on GitHub&lt;/li&gt;
&lt;li&gt;Clone the forked repository&lt;/li&gt;
&lt;li&gt;Make changes in the &lt;code&gt;master&lt;/code&gt; branch&lt;/li&gt;
&lt;li&gt;Push to the forked repository&lt;/li&gt;
&lt;li&gt;Open the pull request&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ok, that works. However, adding the second pull request changes the dynamic. Making changes to that same &lt;code&gt;master&lt;/code&gt; branch will affect the original (first) pull request, so let's not do that. Branching off of &lt;code&gt;master&lt;/code&gt; now will include the changes you've already made for PR #1. Some people might tell you to do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fork the repository on GitHub again (this will create a &lt;code&gt;test-project-1&lt;/code&gt; repository)&lt;/li&gt;
&lt;li&gt;Clone the forked repository&lt;/li&gt;
&lt;li&gt;Make changes in &lt;em&gt;that&lt;/em&gt; repository's &lt;code&gt;master&lt;/code&gt; branch&lt;/li&gt;
&lt;li&gt;Push to the forked repository&lt;/li&gt;
&lt;li&gt;Open the pull request&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Obviously, if you wanted to open a third, fourth, or even a fifth pull request, this becomes unweildy. Did I make that change in &lt;code&gt;test-project-2&lt;/code&gt; or &lt;code&gt;test-project-4&lt;/code&gt;?&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;How could you combat this? Branching! When initially cloning the first repository, start by creating a branch for the thing your PR solves:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; first-pull-request
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This creates and checks out the &lt;code&gt;first-pull-request&lt;/code&gt; branch. Make your changes for PR #1 and push them to GitHub. You can now open your first PR on GitHub.&lt;/p&gt;

&lt;p&gt;Adding a second PR couldn't be easier:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Ensure you're on master!&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;git checkout master
&lt;span class="nv"&gt;$ &lt;/span&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; second-pull-request
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Again, make your changes and push them to GitHub. Now you can safely open the second pull request without having to worry about conflicting with the first one!&lt;/p&gt;


</description>
      <category>git</category>
      <category>branching</category>
      <category>forking</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
