How to fix error: No refs in common and none specified; doing nothing in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 214 views

This Git error occurs when you try to push to a remote repository that has no common references with your local repository. It typically happens when pushing to an empty remote or when using git push without specifying a branch.

Quick fix

Fixes error: No refs in common and none specified; doing nothing

# If your branch is named main
git push -u origin main

# If your branch is named master
git push -u origin master
  1. Push with explicit branch name
  2. Check your current branch name
  3. Ensure you have at least one commit
  4. Use HEAD to push current branch
git โ€” error
# If your branch is named main
git push -u origin main
# If your branch is named master
git push -u origin master
error: No refs in common and none specified; doing nothing

What this error means

When Git displays "No refs in common and none specified; doing nothing", it means the push operation cannot proceed because Git cannot find any matching branches between your local repository and the remote. By default, Git's push behavior (called "matching") tries to push all local branches that have corresponding branches on the remote. When the remote repository is empty or has no branches that match your local ones, Git finds nothing to push and gives up. This is Git's way of saying: "I don't know what you want me to push, and I couldn't figure it out automatically either." The error often appears after cloning an empty repository, adding files, and then trying to push without explicitly specifying which branch to push.

Typical symptoms

  • Running git push with no arguments outputs "No refs in common and none specified; doing nothing"
  • The push command completes without errors but nothing gets pushed to the remote
  • Message suggests specifying a branch such as "master" or "main"
  • Remote repository appears empty after push attempt
  • Occurs frequently when pushing to a newly created remote repository

Common causes

  1. Remote repository is empty with no branches - there are no references to match against
  2. Running git push without specifying a branch name when Git cannot infer which branch to push
  3. Branch name mismatch between local (e.g., main) and expected remote (e.g., master)
  4. Local repository has no commits yet, so there is nothing to push
  5. The push.default configuration is set to "matching" and no branches match

How to fix "error: No refs in common and none specified; doing nothing"

1Push with explicit branch name

Specify the branch you want to push explicitly. This is the most common solution:

bash
# If your branch is named main
git push -u origin main

# If your branch is named master
git push -u origin master

The -u flag sets the upstream tracking, so future pushes will work with just git push.

2Check your current branch name

Verify what your local branch is actually called:

bash
git branch

The current branch will be marked with an asterisk (*). Make sure you're pushing the correct branch name. Modern Git defaults to "main", but older setups may use "master".

3Ensure you have at least one commit

If your repository has no commits, there is nothing to push. Create an initial commit first:

bash
git add .
git commit -m "Initial commit"
git push -u origin main

You cannot push an empty repository - Git needs at least one commit to create a branch reference.

4Use HEAD to push current branch

If you're unsure of your branch name, push HEAD directly:

bash
git push origin HEAD:main

This explicitly pushes your current HEAD to the remote branch called "main", regardless of what your local branch is named.

5Configure push.default for convenience

Set Git to automatically push the current branch:

bash
git config --global push.default current

With this setting, git push will push your current branch to a remote branch of the same name, creating it if necessary. Other options include:
- simple (default in Git 2.x): Push current branch to its upstream
- upstream: Push current branch to its upstream branch
- matching: Push all matching branches (legacy default)

Advanced notes

### Understanding push.default modes

Git has several push behavior modes that affect what happens when you run git push without arguments:

- nothing: Produces an error; you must always specify what to push
- current: Push the current branch to a same-named branch on the remote
- upstream: Push the current branch to its configured upstream
- simple: Like upstream, but refuses if the upstream branch name differs (safest, default since Git 2.0)
- matching: Push all local branches that have matching remote branches (pre-2.0 default)

The "no refs in common" error often occurs with the old "matching" default when the remote is empty.

### Checking remote repository state

To verify what the remote repository contains:

bash
git ls-remote origin

An empty result confirms the remote has no branches yet. You must push with an explicit branch name to create the first reference.

### Branch name conventions

GitHub, GitLab, and other platforms have shifted from "master" to "main" as the default branch name. When creating remote repositories, check what default branch name the platform expects and match your local branch accordingly:

bash
# Rename your local branch if needed
git branch -m master main
git push -u origin main

Frequently asked questions

What does "error: No refs in common and none specified; doing nothing" mean?
When Git displays "No refs in common and none specified; doing nothing", it means the push operation cannot proceed because Git cannot find any matching branches between your local repository and the remote. By default, Git's push behavior (called "matching") tries to push all local branches that have corresponding branches on the remote. When the remote repository is empty or has no branches that match your local ones, Git finds nothing to push and gives up.
How do I fix "error: No refs in common and none specified; doing nothing"?
This Git error occurs when you try to push to a remote repository that has no common references with your local repository. It typically happens when pushing to an empty remote or when using git push without specifying a branch.
What causes "error: No refs in common and none specified; doing nothing"?
Remote repository is empty with no branches - there are no references to match against Running git push without specifying a branch name when Git cannot infer which branch to push Branch name mismatch between local (e.g., main) and expected remote (e.g., master)
Is the "error: No refs in common and none specified; doing nothing" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading