To rename a git branch from its name master to main make use of the git branch command with -m or --move option.
Let us see few examples:
% git branch master * ticket-123
As you can see, I have two branches currently for my repo and one of them is master which I want to rename as main.
% git branch --move master main % git branch main * ticket-123
As you can see after using the move option along with git branch command the master branch was renamed to main successfully!
Note: If the main branch already exists you will get an error!
% git branch --move master main fatal: a branch named 'main' already exists
Have Questions? Post them here!
- Git: Delete Branch Locally and Remotely at Origin
- How to change directory in Git bash
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- Get List of all local branches git command
- How to check your installed version of Git
- fatal: Unable to create '/c/git_repo/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.
- git command to remove/unstage files from staging area
- fix fatal: --local can only be used inside a git repository error
- Github: How to Invite Collaborators
- How to Install Git on Windows
- Get the file location of git config values
- Change the default diff or commit editor for git
- GitHub: How to Search Code
- [fix] zsh: command not found: git
- Setup Git + Visual Studio Code Tutorial
- Fix [oh-my-zsh] Can't update: not a git repository
- [fix] fatal: this operation must be run in a work tree in git
- Git: Step-by-Step - How to Push Local Brach to GitHub
- How to ignore files in git using .gitignore file
- Rename git branch on Local and GitHub Remove using Command
- Change the default git branch name from master to main
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021
- Git Remove Untracked Files using Command
- git fatal: Authentication failed error [fix]
- Git Rename master branch make to main using Command
- Where are Plugins Installed in Notepad++ - NotepadPlusPlus
- Java Jackson ObjectMapper Class with Examples - Java
- Restore deleted Office 365 SharePoint group site - SharePoint
- MySQL Error :1006 SQLSTATE: HY000 (ER_CANT_CREATE_DB) Message: Can't create database 'mydb' (errno: 28) - MySQL
- How to Install Compare Two Files Plugin in Notepad++ - NotepadPlusPlus
- Java 8 JDBC: Insert Timestamp Code Example - Java
- Notepad++ Replace space with Dot - NotepadPlusPlus
- Test internet speed using macOS Terminal command - MacOS