I wanted to rename a branch in one of our (Git) repositories. The way to do this is to
- delete the branch on the server (done),
- rename the local branch (done)
- and then push the renamed branch to the server.
This last step fails, like this:
> git push origin New_Branch_Name
Counting objects: 1374, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (145/145), done.
Writing objects: 100% (478/478), 34.37 MiB | 8.36 MiB/s, done.
Total 478 (delta 349), reused 455 (delta 332)
remote: error: unable to write sha1 filename ./objects/pack/pack-c4fe98c613c55dc30b0e148d41c11a6fb68857ac.pack: Permission denied
remote: fatal: cannot store pack file
error: unpack failed: index-pack abnormal exit
To http://stash/repo_address.git
! [remote rejected] New_Branch_Name -> New_Branch_Name (unpacker error)
error: failed to push some refs to 'http://stash/repo_address.git'
[I can push to all the other repos on the server and all the other branches of this repo without problems.]
I tried the following:
- searching for a process that has a lock on this file (there is none)
- restarting the server to make sure there is no process locking the file (several times)
- running git gc on the server in the repo's folder
- running git gc --aggressive on the server (runs out of 2*32GB real+virtual RAM before it completes)
- copying the whole repo folder to a different computer and trying to push to the copy (fails the same way, which makes me believe there is a problem with the pack file or one of its properties.)
- checking the file permissions of the file mentioned (my user has Admin rights on the server and Admins have "full control" access to the file)
None of these change the result.
The repo is a live one with quite many active users and a history of ~100 pull requests I cannot afford to lose, so deleting and re-pushing the whole repo is not an acceptable option (unless there is a way to migrate the PR's to the new copy).
Any suggestions for what could be wrong and how I could fix it?