Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete remote branch on phpstorm after I delete on gitlab?

How to delete remote branch on phpstorm after I delete on gitlab

After deleting that branch on GitLab, I cannot select the same branch in my PhpStorm-managed local repo without seeing the error message:

Failed to delete remote branch origin/branch1

unable to delete 'branch1': remote ref does not exist failed to push
some refs to 'http://[email protected]/owner/projectname.git'

How can I avoid that error message?

like image 910
Ton Avatar asked Feb 17 '15 09:02

Ton


People also ask

Does deleting a branch delete remote?

Pushing to delete remote branches also removes remote-tracking branches. Note that deleting the remote branch X from the command line using a git push will also remove the local remote-tracking branch origin/X , so it is not necessary to prune the obsolete remote-tracking branch with git fetch --prune or git fetch -p .

How do I force delete a remote branch?

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 .

How do I delete a remote branch without deleting locally?

How to Delete a Branch Remotely. 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>.


1 Answers

This is seen when a remote repo has no longer a specific branch, but an IntelliJ GUI like PhpStorm still reference it as a remote tracking branch.
See IDEA-96402 (Dec. 2012, not yet closed):

Remote branches on a project hosted on bitbucket.org don't exist anymore, but are still listed on my phpstorm installation.

  1. Bitbucket does not list the branch anymore
  2. When I select the branch to delete from within PHPSTORM, i receive the message
Failed to delete remote branch origin/hotfix/bug-121: null: NON_EXISTING

The workaround is for now a manual one:

  1. You can call git remote prune origin in the command line.
  2. If you call Update Project to pull from the remote, it will automatically prune all obsolete references.

The ticket adds:

Note that if you delete a remote branch from the IDE or from the command line, the reference is deleted as well.
This request is about deleting remote reference on the branch which was removed from the remote via some other way, not from this repository.

like image 169
VonC Avatar answered Nov 15 '22 11:11

VonC