I need to rename branch “branch” to “branch_old” in gitlab,
I searched for it and found that I need to do the following
- Checkout the branch locally.
- Rename it locally
- delete remote branch
- push the locally renamed branch to remote.
When I do this I get errors of pre-recive hooks rejecting the deletion of protected branches.
Then I go to gitlab and delete the protected branch via GUI and when I try to push the new branch, I get the following
$ git push --set-upstream origin branch_old
Counting objects: 8450, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4249/4249), done.
Writing objects: 100% (8450/8450), 5.03 MiB | 3.19 MiB/s, done.
Total 8450 (delta 6592), reused 5965 (delta 4199)
remote: Resolving deltas: 100% (6592/6592), completed with 695 local objects.
remote: fatal: bad object 0000000000000000000000000000000000000000
- [new branch] branch_old -> branch
Branch ‘branch_old’ set up to track remote branch ‘branch’ from ‘origin’.
In gitlab gui, I see the “branch” being restored.
What am I doing wrong? what is the correct way to rename a branch in Gitlab.?