Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I delete a branch in a remote GitLab repository?

Tags:

git

gitlab

I'm trying to delete a branch both locally and in a remote GitLab repository. Its name is origin/feat. I tried git push --delete origin feat. Git complains:

remote: error: By default, deleting the current branch is denied, because the next remote: 'git clone' won't result in any file checked out, causing confusion. remote:  remote: You can set 'receive.denyDeleteCurrent' configuration variable to remote: 'warn' or 'ignore' in the remote repository to allow deleting the remote: current branch, with or without a warning message. remote:  remote: To squelch this message, you can set it to 'refuse'. remote: error: refusing to delete the current branch: refs/heads/feat 

OK makes sense, so I tried switching to origin/master with git checkout master and it tells me: Already on 'master'. Does the current branch also need to be set in the remote directory? How would I do that?

like image 339
smcs Avatar asked Jun 20 '17 16:06

smcs


People also ask

How can you delete a branch in a remote repository?

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.

Why can't I delete my git branch?

A: Git doesn't allow you to delete a local branch if you have the branch checked out. If you're having trouble deleting a Git branch, make sure you Git checkout a branch other than the one you want to delete.

Can you delete a branch in a local and in a remote repository?

You'll often need to delete a branch not only locally but also remotely. To do that, you use the following command: git push <remote_name> --delete <branch_name>. The branch still exists locally, though.

How do I delete a branch in SSH?

Delete branches We can delete a branch by calling the branch command and passing in the -d option, followed by the branch name.

How to delete a remote branch in Git?

The command to delete a remote branch is: 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.

How to delete the Master of a GitLab repository?

Assuming you want to delete the master, I resolved the problem in 3 steps: 1 Go to the GitLab page for your repository, and click on the “ Settings ” button. 2 In Default Branch, switch the default branch from your master to other one. 3 In Protected Branches, if there's any protection, unprotect the master. More ...

What is a repository branch in Git?

Repos often have a main branch for the main codebase and developers create other branches to work on different features. Once work is completed on a feature, it is often recommended to delete the branch. Git will not let you delete the branch you are currently on so you must make sure to checkout a branch that you are NOT deleting.

What is a local branch in Git?

Local branches are branches on your local machine and do not affect any remote branches. The command to delete a local branch in Git is: git branch is the command to delete a branch locally.


1 Answers

Try

git push origin --delete feat

like image 73
Charles Avatar answered Oct 12 '22 17:10

Charles