0

Git v2.32.1

I issue the following commands for my repo

$ git pull origin master
$ git fetch origin
$ git br -a
...
remotes/origin/feature/WOW-1012
...

Now when I try to delete this branch, I get an error.

$ git push origin --delete feature/WOW-1012
error: unable to delete 'feature/WOW-1012': remote ref does not exist
error: failed to push some refs to 'bitbucket.org:workspace/some-git-repo.git'

What am I missing? How can I fix this?

Chris F
  • 14,337
  • 30
  • 94
  • 192

1 Answers1

3

The remote repo exists. The "remote ref" in the error message is the branch. The branch does not exist on the remote.

git branch -a lists your local idea of what's on the remote. It doesn't check the remote. Something else deleted the branch.

It's easy for your remote branches to get out of date. To avoid this, you can tell git fetch (which is behind git pull) to "prune" your remote branches and tags which have been deleted. git pull -p.

You can make this the default, which I recommend, by adding this to your configuration file.

[fetch]
        prune = true
Schwern
  • 153,029
  • 25
  • 195
  • 336