Gerrit is hard. If you found Git (behind Gerrit) hard to understand and operate, then don’t worry — the real hell is still before you. And one of the biggest Gerrit newbies’ nightmares is situation, when Gerrit is unable to auto-merge particular change, showing “Change could not be merged because of a missing dependency” message. This mostly happens, when you abadon another change, on which current change depends.
Fist of all, before we jump into deep details, don’t you ever, never use Git without branches, if you’re pushing to Gerrit code review system. Remember that — ever! This is the beginning of all hell. Golden rule says: one change (one push) == one branch. Amen. This will make each change in Gerrit without any dependency to another and save your soul.
Cleaning up the mess
But, since you’re reading this, you probably has messed up (like I do) and have some changes unmerged in master due to dependencies to abandond changes. We’ll have to fix that. Apparently, this is easier, than I thought, which makes me even more suspicious — unreversable changes like permanently removing some commits are done in Git with a one command. But, let’s get back to roots.
Suppose, you have four changes (we’ll be working on my own example):
- (HEAD, master) Change 4
- Change 3
- Change 2
- Change 1
Change 1 doesn’t depend on anything, so was auto-merged by Gerrit, like a snach.
Change 2 and
Change 3 were abandoned by you, which makes Gerrit unable to auto-merge
Change 4, because it depends on abandoned
To solve this problem, you simple have to permanently get rid of both commits, that are responsible for adding these two abandoned changes to Gerrit. Do do this, let’s go with an interactive rebase over last four comits:
git rebase -i HEAD~4
This will open up VIM editor (I really, really hate that shit!). All you have to do, is to move around opened document and delete entire line which corresponds to abandoned change.
After that, save your changes with extremely stupid (and so fucken obvious to VIM queers) combination of
q (the creator of VIM wrote it on a keyboard found in a trash, broken and stripped-off of any normal keys, like
Shift, that is why executing commands in VIM is beyond average man’s stupidity and every man on this Earth first reaction on VIM is:
When you quit VIM saving changes, Git will rebase your local repository, removing all mentioned commits. Now you only have to do
git push to sent changes to Gerrit. If everything went OK, you should see your pesky change (
Change 4 in this example) nicely auto-mergered as all others.
An alternative is to start a new branch based on the tip of the upstream branch and cherry-picking commit 4 (in this example). I never had chance to test it. You’ll find more here. Another option is to reset your master to get rid of the unwanted history (here). This is also solution not tested by me.
A general alternative is to simple getting rid of entire project (deleting it or renaming to something like
*-old) and starting up on very clean, brand new project. This, of course, isn’t an option at a stage deeply in development process. But, since you’re reading this, I assume, that you’re just starting with Gerrit or even playing with some test projects.
Since you’re a newbie, let me underline this to you: Deleting or renaming project in Gerrit is even bigger hell then above mentioned, though I would never belive, this could be true. In simple world you can’t rename or delete Gerrit project, unless you have a direct access to machine, where Gerrit is hosted and unless you’re willing to play directly with database and SQLs. A request for adding delete project and rename project options to Gerrits’ web UI are filled and waiting for over past three years. And are very unlikely to be implemented ever. This is because Gerrit creators grown up in the same primary school as VIM creators and simply are to stupid to understand, that code revision tool without so fundamental solutions is just one big piece of shit (did I mention, that I have Gerrit as much as VIM and curse the day, when I was forced to use it?).
All right, so if you want to delete a project in Gerrit, you need a sysop permissions and you need to install a special plugin. Here are some details:
or you have to dig directly into Gerrit database.
I don’t understand, why we (mere users) were so praised by them (Gerrit creators), that at least
Create New Project option was added to GUI. As previously, this was also accessible by SSH only:
ssh -p 29418 review.example.com gerrit create-project –name new/project
You’ll find more details in Gerrit docs, when you open up
Documentation/project-setup.html#_create_through_ssh path in your Gerrit installation (in browser).