0

I cloned a global project

git clone https://github.com/lornajane/scripts.git scripts

And I added remote branch

git remote add gitlab  http://ankits@abc.xyz/janedoe/my.git
git push gitlab master -f

Now the problem is I don't have http://ankits@abc.xyz/janedoe/my.git project anymore on gitlab.

So when I tried deleting remote branch

git push gitlab --delete master

I got error:

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/master
To http://ankits@abc.xyz/janedoe/my.git
 ! [remote rejected] master (deletion of the current branch prohibited)

How do remove this remote. Thanks!

Romeo
  • 147
  • 1
  • 3
  • 11
  • Possible duplicate of [how to remove remote origin from git repo](https://stackoverflow.com/questions/16330404/how-to-remove-remote-origin-from-git-repo) – 1615903 Aug 16 '17 at 08:32

2 Answers2

1

You added the remote repo with git remote with add so you can remove it with rm. Try git remote --help for a full listing.

git remote rm gitlab should work for what you wanna do.

Billy Ferguson
  • 1,429
  • 11
  • 23
  • Hi Bily, That seems to work! I can't seem to understand difference between using git remote rm and git push --delete. Any help understanding – Romeo Aug 15 '17 at 15:38
  • So the former `git remote rm` just removes the reference to the remote repo. Your `--delete` physically deletes that branch off the face of the earth FOREVER. One is removing a link. The second one is phycally removing the existence of that repo/branch – Billy Ferguson Aug 15 '17 at 16:11
  • The rm is like deleting a symbolic link in a unix directory. Your `--delete` is like `cd`ing to that symbolic link and deleting the directory and all of its contents. – Billy Ferguson Aug 15 '17 at 16:15
  • Thanks...make sense now – Romeo Aug 15 '17 at 18:47
0

You cannot delete the current remote "HEAD" branch..

Matias Elorriaga
  • 8,880
  • 5
  • 40
  • 58