Skip to content

Instantly share code, notes, and snippets.

@MonkmanMH
Created October 7, 2020 14:24
Show Gist options
  • Save MonkmanMH/b0b6c9b57e3b33b04b019710184c2385 to your computer and use it in GitHub Desktop.
Save MonkmanMH/b0b6c9b57e3b33b04b019710184c2385 to your computer and use it in GitHub Desktop.
Rename GitHub repos
---
title: "rename github repo"
author: "Martin Monkman"
date: "2020/10/05"
output: html_document
---
From
https://www.r-bloggers.com/2020/07/5-steps-to-change-github-default-branch-from-master-to-main/
## Steps 1-3
```{bash}
# Step 1
# create main branch locally, taking the history from master
git branch -m master main
# Step 2
# push the new local main branch to the remote repo (GitHub)
git push -u origin main
# Step 3
# switch the current HEAD to the main branch
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
```
## Step 4
At this point you have to open your browser and change the default branch on GitHub to main
How-to:
https://docs.github.com/en/github/administering-a-repository/setting-the-default-branch
## Step 5
```{bash}
# Step 5
# delete the master branch on the remote
git push origin --delete master
# check the repo
git branch -a
```
That's it!
-30-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment