How to change git default branch from master

How to change git default branch from master

Change the default branch name from master to other. Recently, there are many suggestions about renaming the default branch master to some other name.

Recently, there are many suggestions about renaming the default branch *master *to some other name. This was mainly due to the master-slave metaphor.

There is evidence that states it was intended to mention master-copy **or master recording. **And it is not intended to be master-slave.

But I think it’s people’s perspective, and they should be empowered to make this change.

So let’s see how to change the default git branch master to default (you can use your preferred name)

Before starting I have to tell you that I have tried this in multiple repos and it’s working fine without any breaking changes. If you are not confident enough then fork your repo and try it first.


  1. Make sure your CI/CD flow doesn’t get interrupted.
  2. Make sure you have merged all the PRs targeting master. Other PRs are fine

There are three steps in renaming the default branch

  1. Change the branch name
  2. Set remote upstream tracking for the new branch
  3. Change the new branch name in repo host (Github, Gitlab)

Change the branch name

git branch -m master default

The above command just renames the default branch to the name default.

-m attribute is used to rename the branch name without affecting the branch’s history.

Image for post

Now the default branch is changed in the local but not in the remote.

Set remote upstream tracking for the new branch

coding programming github software-development git

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

5 Core Criteria for Selecting Software Development Company -

Check out these five criteria for the selection of your software vendor, and you will never regret having the wrong quality product made for you.

How to Get Started with Parallel Programming in Git in Under 2 Minutes

There are many Git tips and best practices available on the internet that can help you in your day to day activities. You can save you valuable time, and stay productive with best practices and you can improve your workflow. One of the cool things in the Git is to do parallel programming.

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…

ERP Software Services, POS Software Services , Application Development

Vinew Technologies focused majorly over ERP Software services and POS Software services, Web & Application development services & Woo commerce and Wordpress easy-to-use, multipurpose social media plugin for WordPress.