0

I push to Gerrit, and my code is reviewed such that valid comments are made. I make the changes, and do a fresh commit and push, assuming that I’ve created a new patch set.

However, I forget to tick the ‘Amend commit’ box in IntelliJ:

enter image description here

This means that the new commit gets pushed to Gerrit with a new Change-Id, and so the change does not become associated with the previous push. Now my reviewers can’t (easily) make the connection between the 2 changes, nor can anyone who looks at this in the future.

My commit messages are multi-line, and so cannot easily be altered on the command line if I wanted to do a git amend.

My approach has been to try and undo the ‘bad’ commit --- but I end up getting confused in Git Hell.

I end up:

  1. checking out origin/master into a new repo on my laptop and
    manually making my changes again (yes, really), then
  2. deactivating the commit-msg hook in my .git/hooks directory, then
  3. making a commit with the desired Change-Id manually added to the message, then
  4. pushing to Gerrit.
  5. Finally I re-activate the commit-msg hook

This can’t be the best way to do it. It works, but it can’t be the best way to do it.

What do?

Return_Of_The_Archons
  • 1,731
  • 3
  • 20
  • 26

1 Answers1

1

You should squash the two last commit into one, keeping in the message the initial Change-ID. The squash allow you to combine different commits into one. It takes place into interactive rebase process. The explanation to do it using command line.

You could use this example to do using interface.

Community
  • 1
  • 1
Flows
  • 3,675
  • 3
  • 28
  • 52