squash commits first

With this error message Gerrit rejects to push a commit if it
contains the same Change-Id as a predecessor commit.

The reason for rejecting such a commit is that it would introduce, for
the corresponding change in Gerrit, a dependency upon itself. Gerrit
prevents such dependencies between patch sets within the same change
to keep the review process simple. Otherwise reviewers would not only
have to review the latest patch set but also all the patch sets the
latest one depends on.

This error is quite common, it appears when a user tries to address
review comments and creates a new commit instead of amending the
existing commit. Another possibility for this error, although less
likely, is that the user tried to create a patch series with multiple
changes to be reviewed and accidentally included the same Change-Id
into the different commit messages.

Example

Here an example about how the push is failing. Please note that the
two commits 'one commit' and 'another commit' both have the same
Change-Id (of course in real life it can happen that there are more
than two commits that have the same Change-Id).

If it was the intention to rework a change and push a new patch
set, the problem can be fixed by squashing the commits that contain the
same Change-Id. The squashed commit can then be pushed to Gerrit.

To squash the commits, use git rebase -i to do an interactive rebase. For
the example above where the last two commits have the same Change-Id,
this means an interactive rebase for the last two commits should be
done. For further details about the git rebase command please check
the Git documentation for rebase.

If it was the intention to create a patch series with multiple
changes to be reviewed, each commit message should contain the
Change-Id of the corresponding change in Gerrit. If a change in
Gerrit does not exist yet, the Change-Id should be generated (either
by using a commit hook or by using EGit) or the Change-Id could be
removed (not recommended since then amending this commit to create
subsequent patch sets is more error prone). To change the Change-Id
of an existing commit do an interactive git rebase and fix the
affected commit messages.