Software⏱️ 2 min read📅 2026-05-31

How to Fix: fatal: Not a valid object name: 'master'

Git branch not created due to bare repository initialization.

Quick Answer: When initializing a bare Git repository, use git init --bare instead of just git init. This will create the necessary files and allow you to create branches.

The error message 'fatal: Not a valid object name: 'master'' indicates that Git is unable to recognize the master branch. This issue can occur when using a bare Git repository, which is created with `git --bare init`. In this case, the master branch does not exist by default.

⚠️ Common Causes

  • Using a bare Git repository created with `git --bare init`.

✅ Best Solutions to Fix It

Method 1: Create a new branch

  1. Step 1: Run `git branch ` to create a new branch.

Method 2: Use `--bare` with `--init`

  1. Step 1: Run `git --bare init --branch ` to create a new branch in the bare repository.

✨ Wrapping Up

To resolve this issue, you can either create a new branch using `git branch `, or use the `--bare` option with `--init` to create a new branch in the bare repository.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions