I have tried the following command and it fails.
git push origin :next
remote: error: denying ref deletion for refs/heads/next
To blah.git
! [remote rejected] next (deletion prohibited)
error: failed to push some refs to 'blah.git
I am using gitolite and cannot find any of this error message in the hooks. How can I disable this so that I can delete or rename this remote branch? When I run git branch -r -d origin/next, it appears to go away, but the next git pull brings it right back.
Deleting remote branches To delete a remote branch, you can't use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name ( origin in this case) after git push .
Instead of using the git branch command that you use for local branches, you can delete a remote branche with the git push command. Then you specify the name of the remote, which in most cases is origin . -d is the flag for deleting, an alias for --delete . remote_branch_name is the remote branch you want to delete.
Delete a branch The -f or --force flag in combination with -d (or --delete ), allows deleting the branch containing unmerged changes.
You can use the prune subcommand of git-remote for cleaning obsolete remote-tracking branches. Alternatively, you can use the get-fetch command with the --prune option to remove any remote-tracking references that no longer exist on the remote. That's all about deleting remote-tracking branches in Git.
Make sure in your gitolite config, you have the rewind flag on so instead of RW
use RW+
. That will allow you to delete branches and commits.
git push -f origin :next
This looks like the error you get when you try to push to a repo that has denyDeletes = true
. It's intended to prohibit you from rewriting history in the remote (it is usually accompanied by denyNonFastForwards = true
). That being the case, you can only delete the branch by deleting it on the remote; --force
won't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With