<?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: Randy</title>
    <description>The latest articles on DEV Community by Randy (@rowland007).</description>
    <link>https://dev.to/rowland007</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%2F40870%2F98fb1fba-b3ae-4341-8a13-9ae883afc8e4.jpeg</url>
      <title>DEV Community: Randy</title>
      <link>https://dev.to/rowland007</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rowland007"/>
    <language>en</language>
    <item>
      <title>Working with upstream repos</title>
      <dc:creator>Randy</dc:creator>
      <pubDate>Sun, 15 Sep 2019 07:02:36 +0000</pubDate>
      <link>https://dev.to/rowland007/working-with-upstream-repos-3g5a</link>
      <guid>https://dev.to/rowland007/working-with-upstream-repos-3g5a</guid>
      <description>&lt;p&gt;A downstream repository (aka a “&lt;em&gt;fork&lt;/em&gt;”) maintainer commonly needs to stay current with upstream work (aka "&lt;em&gt;original&lt;/em&gt;"). The case is development continues on the upstream repo while you work on your own origin fork. You want to fetch the upstream changes and apply them to your origin so you don't make conflicts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pHOr6y6s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.stack.imgur.com/LtFGa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pHOr6y6s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.stack.imgur.com/LtFGa.png" alt="image cannot be displayed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following steps allow you to achieve this on the command line in a local git repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add the Remote Upstream Repository
&lt;/h2&gt;

&lt;p&gt;This step defines the upstream repository of your fork. First is the syntax followed by an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git remote add &amp;lt;any_name_you_choose&amp;gt; &lt;span class="o"&gt;[&lt;/span&gt;Upstream git URL]
git remote add upstream https://github.com/QubesOS/qubes-doc.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Fetch the Upstream Branches
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch &amp;lt;the_name_you_chose_earlier&amp;gt;
git fetch upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Merge Upstream Changes into your Downstream Repository
&lt;/h2&gt;

&lt;p&gt;From your master branch, use the following merge command to merge the upstream master branch changes into your local source:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout origin/master
git merge upstream/master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You then can either merge into the branch you were previously working on or start a new branch. Since starting a new branch is easy, this sample is merging the master branch into the develop branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout origin/develop
git merge origin/master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Workflow Example
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4eZT9BI8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.rhodecode.com/RhodeCode-Enterprise/_images/git-flow-diagram.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4eZT9BI8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.rhodecode.com/RhodeCode-Enterprise/_images/git-flow-diagram.png" alt="image cannot be displayed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You &lt;em&gt;fork&lt;/em&gt; from the upstream repo using clone and then create a &lt;em&gt;local&lt;/em&gt; copy on your computer.&lt;/li&gt;
&lt;li&gt;You create a new branch branch-1 off of the master branch to do your work on.&lt;/li&gt;
&lt;li&gt;You push those commits from branch-1 to your own origin repo.&lt;/li&gt;
&lt;li&gt;You then create a &lt;em&gt;pull request&lt;/em&gt; with the upstream repo into the master branch.&lt;/li&gt;
&lt;li&gt;Your &lt;em&gt;pull request&lt;/em&gt; is merged into the master branch and development continues on the upstream master branch past your &lt;em&gt;local&lt;/em&gt; and origin repo.&lt;/li&gt;
&lt;li&gt;You then have to fetch the upstream repo before you continue your work to avoid conflicts&lt;/li&gt;
&lt;li&gt;You then push the upstream changes to your origin repo keeping origin up-to-date with upstream.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Legend
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Access&lt;/th&gt;
&lt;th&gt;Upstream&lt;/th&gt;
&lt;th&gt;Origin&lt;/th&gt;
&lt;th&gt;Local&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Own&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remote&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>git</category>
    </item>
  </channel>
</rss>
