# Change GitHub default branch from master to main

### Step 1 
Create main branch locally, taking the history from master
```bash
git branch -m master main
 ```

### Step 2 
Push the new local main branch to the remote repo (GitHub) 
```bash
git push -u origin main
```

### Step 3
Switch the current HEAD to the main branch
 ```bash
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
```

### Step 4
Change the default branch on GitHub to main

At this point you’ve succesfully transitioned everything to the ‘main’ branch, but you can’t delete the ‘master’ branch without changing the default branch in GitHub to something other than ‘master’. For this:
- Navigate to your github repository
- click "Settings" -> "Branches"  on the sidebar
- Change the default branch to ‘main’. 

*For detail instruction check [setting the default branch on github](https://docs.github.com/en/github/administering-a-repository/setting-the-default-branch)*

### Step 5
Delete the master branch on the remote
```bash
git push origin --delete master
```
