<?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: welchi</title>
    <description>The latest articles on DEV Community by welchi (@welchi).</description>
    <link>https://dev.to/welchi</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%2F497043%2Febd7032f-ec16-41de-bc3c-4d0a1f30364e.png</url>
      <title>DEV Community: welchi</title>
      <link>https://dev.to/welchi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/welchi"/>
    <language>en</language>
    <item>
      <title>Rename the branch from "master" to "main" in an existing GitHub repository</title>
      <dc:creator>welchi</dc:creator>
      <pubDate>Fri, 23 Oct 2020 02:56:55 +0000</pubDate>
      <link>https://dev.to/welchi/rename-the-branch-from-master-to-main-in-an-existing-github-repository-3f70</link>
      <guid>https://dev.to/welchi/rename-the-branch-from-master-to-main-in-an-existing-github-repository-3f70</guid>
      <description>&lt;h2&gt;
  
  
  What I want to do
&lt;/h2&gt;

&lt;p&gt;Sometimes I want to change the name of a branch, both locally and remotely.&lt;br&gt;
For example, I may want to change the name of the branch from master to main. &lt;br&gt;
This article will show you how to do that.&lt;/p&gt;
&lt;h2&gt;
  
  
  Procedure
&lt;/h2&gt;

&lt;p&gt;First, locally, rename the branch from master to main.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch &lt;span class="nt"&gt;-m&lt;/span&gt; master main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you'll add the main branch to the remote.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fok7ei1ppweyis7ke22f8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fok7ei1ppweyis7ke22f8.png" alt="スクリーンショット_2020-10-13_23_48_51eng"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also set the main branch as the default branch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzrqp5w6wjnfinxudyv0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzrqp5w6wjnfinxudyv0h.png" alt="スクリーンショット_2020-10-13_23_51_133eng"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then delete the master branch in the remote.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin :master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, the local main branch follows the remote main 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 push &lt;span class="nt"&gt;--set-upstream&lt;/span&gt; origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/lttlrck/9628955" rel="noopener noreferrer"&gt;rename git branch locally and remotely&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.git-tower.com/learn/git/faq/set-upstream/" rel="noopener noreferrer"&gt;Git Set Upstream | Learn Version Control with Git&lt;/a&gt;&lt;/p&gt;

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