After trying to run Jenkins tests on a GitHub Pull Request, I'm running into the following error:
error: some local refs could not be updated; try running
00:07:44 'git remote prune git@github.com:myrepo/myrepo.git' to remove any old, conflicting branches
Running any or all of the following does not fix it:
git remote prune git@github.com:myrepo/myrepo.git
git remote prune origin
git fetch origin -t --prune
git gc --prune=now
Jenkins is running this command in its workspace:
git fetch --tags --progress origin +refs/pull/*:refs/remotes/origin/pr/*
Which shows me that there is a bad ref on the remote:
git fetch --tags --progress origin +refs/pul
l/*:refs/remotes/origin/pr/*
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
error: 'refs/remotes/origin/pr/2730' exists; cannot create 'refs/remotes/origin/pr/2730/head'
From github.com:myrepo/myrepo
! [new branch] refs/pull/2730/head -> origin/pr/2730/head (unable to update local ref)
error: some local refs could not be updated; try running
'git remote prune origin' to remove any old, conflicting branches
There is a ticket closed as Won't Fix
on Jenkins about a similar error: JENKINS-19591
I've tried deleting the remote ref:
git push origin :refs/origin/pr/2730/head
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
remote: warning: Deleting a non-existent ref.
To git@github.com:myrepo/myrepo.git
- [deleted] refs/origin/pr/2730/head
I still run into the same error afterwards :-(
How can I fix the remote Pull Request ref?
After checking in .git/logs/refs/remotes/origin/pr/
I found that the branch it is complaining about is the only one which is a normal file:
$ ls -ld .git/logs/refs/remotes/origin/pr/273*
drwxrwxr-x 2 jenkins jenkins 4096 Mar 21 08:05 .git/logs/refs/remotes/origin/pr/273
-rw-rw-r-- 1 jenkins jenkins 248 Mar 21 08:05 .git/logs/refs/remotes/origin/pr/2730
drwxrwxr-x 2 jenkins jenkins 4096 Mar 21 08:05 .git/logs/refs/remotes/origin/pr/2731
drwxrwxr-x 2 jenkins jenkins 4096 Mar 21 08:05 .git/logs/refs/remotes/origin/pr/2732
drwxrwxr-x 2 jenkins jenkins 4096 Mar 21 08:05 .git/logs/refs/remotes/origin/pr/2733
drwxrwxr-x 2 jenkins jenkins 4096 Mar 21 08:05 .git/logs/refs/remotes/origin/pr/2734
drwxrwxr-x 2 jenkins jenkins 4096 Mar 21 08:05 .git/logs/refs/remotes/origin/pr/2735
$ file .git/logs/refs/remotes/origin/pr/273*
.git/logs/refs/remotes/origin/pr/273: directory
.git/logs/refs/remotes/origin/pr/2730: ASCII text
.git/logs/refs/remotes/origin/pr/2731: directory
.git/logs/refs/remotes/origin/pr/2732: directory
.git/logs/refs/remotes/origin/pr/2733: directory
.git/logs/refs/remotes/origin/pr/2734: directory
.git/logs/refs/remotes/origin/pr/2735: directory
.git/logs/refs/remotes/origin/pr/2736: directory
.git/logs/refs/remotes/origin/pr/2737: directory
.git/logs/refs/remotes/origin/pr/2738: directory
.git/logs/refs/remotes/origin/pr/2739: directory
$ find .git/logs/refs/remotes/origin/pr/ -maxdepth 1 -type f
.git/logs/refs/remotes/origin/pr/2730
$ cat .git/logs/refs/remotes/origin/pr/2730
0000000000000000000000000000000000000000 0c960f4b8bf30109536ec1b7a1d54a636e21fd87 Jenkins <ops@tangogroup.com> 1395389111 +0000 fetch --tags --progress git@github.com:TangoGroup/program_creator.git +refs/heads/*:refs/remotes/origin/*: storing head
The contents look a bit strange... not sure whether that's how it is supposed to be...