0

My BitBucket repository does not show several branches but running git locally in bash:

git fetch --all; git branch -a;

does show those remote branches.

When I try deleting them in git locally:

git push origin --delete <name_of_branch>

I get an error that these branches are not found.

Could these branches be cached locally and can this cache be cleared ?

Dan Bonachea
  • 2,408
  • 5
  • 16
  • 31
VilleLipponen
  • 636
  • 1
  • 13
  • 22
  • Maybe the branches are local and are not on the repo? Try just deleting them `git branch -d `? – evolutionxbox Dec 07 '22 at 17:26
  • If [this answer](https://stackoverflow.com/a/44129766/184546) helps you, then this is a dup of that question. – TTT Dec 07 '22 at 18:41
  • A `git push origin --delete` is a request that the other Git delete something. If it's not there, there's nothing to delete, which explains your error. Remember that a *remote-tracking name* like `origin/foo` is *local to your personal Git repository* and is remembering that there is, or was at one time, a *branch* `foo` over on `origin`. – torek Dec 08 '22 at 08:29
  • 2
    Meanwhile, as a general rule, don't use `--all`, which doesn't mean what you think it means, with `git fetch` or `git pull`. See [the `git fetch` documentation](https://git-scm.com/docs/git-fetch) for specifics on what it actually means. (If you already know it means "all remotes", not "all branches", this comment is only addressed at other readers of this question.) – torek Dec 08 '22 at 08:30

1 Answers1

0

It sounds like you have a local branch that has not been pushed to the remote.

If the goal is to delete local branch mybranch use a command like:

$ git branch -D mybranch
Dan Bonachea
  • 2,408
  • 5
  • 16
  • 31
  • I think the OP means that `origin/foo` shows up as a remote-tracking name. Since `git branch -D` only deletes *local* branch names, this won't help. However, `git fetch --prune` or `git branch -r -D` would work. – torek Dec 08 '22 at 08:32