fatal: Reference has invalid format

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Problem

Opening a repository and/or changing the visualization to another branch within Bitbucket Server throws the following error in the UI:

1 2 3 4 'C:\Program Files (x86)\Git\cmd\git.exe for-each-ref --sort=-creatordate --format=%(refname)%02%(objectname)%02%(*objectname) refs/tags/' exited with code 128 saying: fatal: Reference has invalid format: 'refs/heads/master (1)'

The following appears in the atlassian-bitbucket.log

1 2 2016-07-27 10:00:00,000 ERROR [http-nio-7990-exec-8] user @10ETR3Gx632x493x0 127.0.0.1 "GET /scm/project/repo.git/info/refs HTTP/1.1" c.a.s.i.s.g.p.h.GitSmartExitHandler Request for repo 'repo' of project 'project' from '127.0.0.1' failed: read process 'C:\Program Files (x86)\Git\cmd\git.exe http-backend' caused an exception Process's error output: fatal: Reference has invalid format: 'refs/heads/master (1)'

Diagnosis

Diagnostic Steps

  1. Find this repository's location on disk in the server in the repository's Settings > Repository Details.

  2. Access the server hosting Bitbucket Server and navigate into the repository's location on disk.

  3. Access the directory refs/heads and confirm you have duplicated entries for your refs, being one the original and another one of the " (1)" appended.

Cause

Something in the file system caused the entries in the refs directory to get duplicated - copies are created with an inconsistent and invalid name, with the convention of having, for instance, " (1)" or " - copy" by the end of their name.

Solution

Resolution

Resolution 1

As it's hard to ensure the repository is consistent after this occurrence, you should ideally restore your instance from the most recent backup you have, making sure you have saved any recent work done after the backup was taken, so you can re-add it.

Resolution 2

The files with " (1)" appended should be merely copies of the originals, so it should be safe to:

  1. Create a full backup of your Bitbucket Server instance.

  2. Stop Bitbucket Server.

  3. Remove the duplicated files.

  4. Start Bitbucket Server.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.