I started using (was forced to) Gerrit, when my project was already in progress, so I pushed "everything" to Gerrit, using git push orgin -all
. Some time ago, I noticed that I also pushed some additional branch, merged into master before starting to play with Gerrit and already locally removed:
$ git branch --all
* master
remotes/oberon/master
remotes/origin/96-fix-key-editors-references
remotes/origin/master
I tried to delete that remote branch, the ususal way (git push origin :remotes/origin/96-fix-key-editors-references
), but I was refused by Gerrit, claiming that I don't have Push
privilege with Force Push
option, which is required to complete this task.
So, I went to Project > Branches
in Gerrit's web UI, marked that branch and was able to delete it, by pushing Delete
button (interesting: I can do something in UI, what I'm prohibited via SSH?).
I thought case is over, until I again executed git branch --all
, only to find out, that Git still reports branch remotes/origin/96-fix-key-editors-references
as existing (result exactly like above).
I again used git push origin :remotes/origin/96-fix-key-editors-references
, just to feed my curiosity, what will happen now, and I got error message saying error: unable to delete '96-fix-key-editors-references': remote ref does not exist
.
So, two questions, but actually one:
How can Gerrit remove branch from web UI, not removing it from Git's repo in the same time?
How can remote branch be listed on list and be undeleteable (as not existing) in the same time?
I'm new to Git and even newer to Gerrit, to I might be missing something obvsious. Sorry for that!
The branch name that you're seeing in the output from git branch --all
is a remote tracking branch; it's a special, read-only branch in your local repository that's synchronized with a branch from a remote each time you fetch. By default, git won't delete them even if the branch is gone from the remote, to give you a chance to recover if you didn't really mean to delete them.
This command will get rid of any stale remote tracking branches that no longer exist in the remote:
git fetch origin --prune
If Gerrit claim that you need Push privilege with Force Push option then you can easily give it from gerrit. just go to Projects > Access then Edit. please see the screen shot for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With