fatal: Reference has invalid format
Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.
Opening a repository and/or changing the visualization to another branch within Bitbucket Server throws the following error in the UI:
'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
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)'
- Find this repository's location on disk in the server in the repository's
Settings > Repository Details.
- Access the server hosting Bitbucket Server and navigate into the repository's location on disk.
- Access the directory
refs/headsand confirm you have duplicated entries for your refs, being one the original and another one of the "
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.
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.
The files with "
(1)" appended should be merely copies of the originals, so it should be safe to:
- Create a full backup of your Bitbucket Server instance.
- Stop Bitbucket Server.
- Remove the duplicated files.
- Start Bitbucket Server.