tony497
tony497

Reputation: 400

Why can I still checkout a branch I deleted on remote GitLab

I have a project on GitLab, from the master I created a branch called Processing-points, not from the command line but with the web interface.

Then I deleted the branch Processing-points, also from the web interface. So everything is ok from the web interface, but on my local computer, I can still checkout the deleted branch. How is that possible?

This is the suggestions I get when I ask to checkout:

ag@ag-Precision-7520:~/catkin_ws/3D_EM$ git checkout 
HEAD                                    origin/master                           origin/Processing-points-multi-thread 
master                                  origin/origin/parallelization           parallelization 
ORIG_HEAD                               origin/parallelization                  pcl_filters 
origin/HEAD                             origin/pcl_filters                      Processing-points-multi-thread

Upvotes: 2

Views: 846

Answers (3)

tony497
tony497

Reputation: 400

I use git branch -r and saw origin/Processing-points in the list. I just had to do git fetch -p to have this response : x [deleted] (none) -> origin/Processing-points-multi-thread and everything seems fine. Thanks for your help!

Upvotes: 0

Marina Liu
Marina Liu

Reputation: 38106

You can troubleshot the issue with below aspects:

  1. Use git branch -r to check if the tracking branch origin/Processing-points exist or not. If it exists, you can use below commands update:

    git fetch -p
    git checkout master #if the HEAD is on local Processing-points branch
    git branch -D Processing-points
    
  2. If the tracking branch origin/Processing-points not exist, that's caused the Processing-points branch already checked out locally before deleting the branch remotely. And Even you deleted the remote Processing-points branch, the local branch Processing-pointsalways exist. And you can use git branch -D Processing-points to delete the local one.

Upvotes: 2

anothernode
anothernode

Reputation: 5397

You can clean up outdated references to remote branches with:

git remote prune origin

Upvotes: 3

Related Questions