<?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: lous code</title>
    <description>The latest articles on DEV Community by lous code (@lous_code).</description>
    <link>https://dev.to/lous_code</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%2F2815812%2F29805372-8689-4ef6-bfdb-2862ed82f219.jpg</url>
      <title>DEV Community: lous code</title>
      <link>https://dev.to/lous_code</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lous_code"/>
    <language>en</language>
    <item>
      <title>Fetching a Remote Branch to the Local Repository in Git</title>
      <dc:creator>lous code</dc:creator>
      <pubDate>Thu, 06 Feb 2025 10:35:50 +0000</pubDate>
      <link>https://dev.to/lous_code/fetching-a-remote-branch-to-the-local-repository-in-git-38eh</link>
      <guid>https://dev.to/lous_code/fetching-a-remote-branch-to-the-local-repository-in-git-38eh</guid>
      <description>&lt;p&gt;To bring a branch from the remote (upstream) repository to the local one, you can use the following commands in &lt;a href="https://burpblog.com/basics-git-for-beginners/" rel="noopener noreferrer"&gt;Git&lt;/a&gt;:&lt;/p&gt;

&lt;h2&gt;
  
  
  **1. Fetching updates from the remote repository
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
First, fetch all branches and updates from the remote repository without merging them into the current branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch origin

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command fetches all updates from the remote origin repository but does not integrate them into the local repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  **2. Checking remote branches
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
After executing fetch, you can view the list of available branches in the remote repository using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch -r
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will show you the branches stored in the remote repository (such as &lt;code&gt;origin/branch-name&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  **3. Create a local branch and track the remote branch
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
If you want to work on a specific branch of the remote repository, you can create a local branch and track it:&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 -b branch-name origin/branch-name

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or using the latest version of &lt;a href="https://burpblog.com/basics-git-for-beginners/" rel="noopener noreferrer"&gt;Git&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git switch --track origin/branch-name

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;This creates a local copy of the remote &lt;a href="https://burpblog.com/basics-git-for-beginners/" rel="noopener noreferrer"&gt;branch&lt;/a&gt; and identifies it as the local master branch.&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;4. Switch to the new branch&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If the branch was previously fetched, you can switch to it directly using:&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 branch-name

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git switch branch-name

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Update the local branch with the latest changes
After fetching the branch, if you need to update it with the latest changes from the remote repository, you can use:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull origin branch-name

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, you will have an updated &lt;a href="https://burpblog.com/basics-git-for-beginners/" rel="noopener noreferrer"&gt;branch&lt;/a&gt; of the remote repository in your local environment, and you can work on it as you like. 🚀&lt;/p&gt;

</description>
      <category>git</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
