Question

How do I rename a branch 'a' to 'master' and rename 'master' to 'b' in gerrit?

I have recently switched to gerrit from a shared git repository.

Was it helpful?

Solution

You can create the "b" branch from master using the web UI: "Admin" -> "Projects" -> "YourProject" -> "Branches". Enter "b" for "Branch Name", and "master" as "Initial Revision", then click the "Create Branch" button.

Now to replace what master is referencing, you have to have "force push" permission on the project, then do:

$ git checkout a
$ git push --force gerrit a:master

This will replace the entire history of the "master" branch with that of the local "a" branch. So be very careful with this, and be sure that's what you want to do.

Finally if you want to remove the 'a' branch in Gerrit, once again go to the web UI's project management screen (same as above), tick the box next to the "a" branch, then click the "Delete" button.

OTHER TIPS

I don't know about gerrit, but generally in git you rename branches by

git branch -m old_branch new_branch
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top