Question

Because of a bad workflow decision on my part, I currently have a local master that is 5 commits ahead of public master.

However there are some new checkins that conflict and the responsibility has been given to me to fix them. I am not a Gerrit admin.

My plan was to create branches for each of my 5 changes individually, cherry-pick the commits over and manually resolve the conflicts, then re-push the fixes so they stick to the correct Gerrit ID:s.

Will this strategy work? And if not, what's one that will?

Was it helpful?

Solution

Since git has no idea about gerrit ids (they are just part of the commit message, as far as git is concerned), this would indeed work. However, note that you may not need a branch for each commit - you could use a single branch, and cherry-pick the relevant commits one at a time and fix the conflicts manually, basing each one on the previous one.

In general, cherry-picking is quite a common tool when managing git projects with gerrit when you want to backport certain patches from the master branch to a specific stable branch whilst preserving the gerrit id.

OTHER TIPS

I think you can rebase instead of cherry-pick.

It would be something like this:

  1. Create a branch for each commit
  2. Reset you master to the orgin master
  3. Rebase commits 2-5 to the master

At this point you should have 5 branches that will all be based on the origin master and can be pushed again with the same Change-id.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top