Search code examples
gitversion-controlgit-branchgit-fetch

Deleted branches after 'git fetch -p'


I try to delete several branches from my project:

leo:Project leo$ git push origin --delete effects
To https://github.com/gituser/Project.git
 - [deleted]         effects
leo:Project leo$ git push origin --delete viewport
To https://github.com/gituser/Project.git
 - [deleted]         viewport

But after fetch --prune that says

After fetching, remove any remote-tracking references that no longer exist on the remote.

I still have deleted branches on local machine:

leo:Project leo$ git fetch -p
leo:Project leo$ git branch -a
  develop
  effects
* master
  viewport
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/master

Any suggestions?


Solution

  • The command did exactly what it said, it deleted "remote-tracking references". This means that any local branch that is connected to a branch on the remote repository gets disconnected, nothing more. That means in particular that the local branch still exists afterwards.

    In order to delete a branch, use git branch -D <branchname>, perhaps make sure you don't lose any commits by first looking at the branch's content.