Anvesh Yalamarthy
Anvesh Yalamarthy

Reputation: 1693

Git Branch is still seen after merging and deleting branches under remote branch list

I'm working on an automation suite, where I have created two branches "p2pOnOff" and "release" branches.

Later I have merged them to master and deleted them using below commands

git branch -d p2pOnOff
git push origin :p2pOnOff

I see that these branches are no more seen in github.com

I'm not able to figure out why I still see them listed as remote branches on my computer

$ git branch --remote
  origin/HEAD -> origin/master
  origin/master
  origin/p2pOnOff
  origin/release

If I try to prune/delete it, I'm getting below error:

$ git remote prune remotes/origin/p2pOnOff
fatal: 'remotes/origin/p2pOnOff' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What am I missing here? How to get rid of them? I have already tried git fetch and git remote update, they didn't help !!

I know, deleting entire folder and cloning it again does the job.. But I'm eager to know if there is any other solution??

Upvotes: 2

Views: 913

Answers (1)

Patrick B.
Patrick B.

Reputation: 12343

Have you tried:

git fetch --prune origin

it works for me in your case.

From the git fetch man-page:

-p, --prune
After fetching, remove any remote-tracking branches which no longer exist on the remote.

To delete refs on remotes you can also use git push --delete which does prune the local reference.

Upvotes: 5

Related Questions