Reputation: 7752
I've deleted a remote branch by running git push origin --delete
from my local machine but when I ssh into a different machine which has a clone of the same git repository I can still see the remote branch with git branch -av
.
Could someone please review the commands I ran and let me know if I've made a mistake or am misunderstanding something.
holy@my-VirtualBox:/var/www/example$ git branch -av
* master 6b49b28 Theme Update
remotes/origin/BL_CustomGrid 8827318 upgraded to BL_CustomGrid
holy@my-VirtualBox:/var/www/example$ git push origin --delete BL_CustomGrid
To staging-box:/var/git/example.git
- [deleted] BL_CustomGrid
holy@my-VirtualBox:/var/www/example$ git branch -av
* master 1f3bb6c Theme Update
remotes/origin/HEAD -> origin/master
remotes/origin/master 1f3bb6c Theme Update
holy@my-VirtualBox:/var/www/example$ ssh staging-box
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-48-generic x86_64)
* Documentation: https://help.ubuntu.com/
[ommiting login messages]
Last login: Tue Nov 17 14:12:36 2015 from 54.??.??.???
STAGING-box@ip-170-??-??-???:~$ cd /var/www/staging-example/
STAGING-box@ip-170-??-??-???:/var/www/staging-example$ git pull
remote: Counting objects: 27, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 10 (delta 7), reused 0 (delta 0)
Unpacking objects: 100% (10/10), done.
From /var/git/example
6b49b28..1f3bb6c master -> origin/master
Updating 6b49b28..1f3bb6c
Fast-forward
skin/frontend/example/default/css/custom.css | 76 +++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
skin/frontend/example/default/sass/_checkout.scss | 9 +++++++++
2 files changed, 56 insertions(+), 29 deletions(-)
STAGING-box@ip-170-??-??-???:/var/www/staging-example$ git branch -av
* master 6b49b28 Theme Update
remotes/origin/BL_CustomGrid 8827318 upgraded to BL_CustomGrid
STAGING-box@ip-170-??-??-???:/var/www/staging-example$ git push origin --delete BL_CustomGrid
error: unable to delete 'BL_CustomGrid': remote ref does not exist
error: failed to push some refs to '/var/git/example.git'
STAGING-box@ip-170-??-??-???:/var/www/staging-example$
I tried removing the git cache after this but it made no difference.
Upvotes: 2
Views: 1506
Reputation: 2294
Your commands are right. Only thing is, that your git repository on the STAGING-box
doesn't know that the branch is deleted. You can show such information with git remote show origin
. You should get something like
[...]
BL_CustomGrid stale (use 'git remote prune' to remove)
[...]
You need to call remote update
with --prune
as option to remove old tracking informations.
git remote update --prune
According to your edit: git pull
merges changes only from the branch which are tracked from your current branch. This is showed in git remote show origin
too:
[...]
Local branches configured for 'git pull':
master merges with master
Local refs configured for 'git push':
master pushes to master
[...]
Upvotes: 10