4

Gerrit accidentally introduced some merge commits (configured with "Merge if necessary" option) and I would like to remove them from the history. I am aware of the pitfalls of rewriting history when team working with Git, but developers will not suffer from this in our case, as none of them have local changes in this particular repository.

I did a git rebase -i locally and Git automatically removed Gerrit's merge commits. I carefully removed the previous Gerrit Change-Ids in each commit messages and the Gerrit commit message hook added new ones.

git status command output:

On branch master Your branch and 'origin/master' have diverged, and have 7 and 9 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working directory clean

Which is what I want (9 commits minus the 2 merge commits).

When I try to push on Gerrit with git push origin HEAD:refs/for/master I get no error. However when I try to review and submit on Gerrit web interface, I get the following error:

The change could not be merged due to a path conflict. Please rebase the change locally and upload the rebased commit for review.

What have I done wrong?

4

1 に答える 1

4

履歴を書き換えるときは、レビューをプッシュしないでください (にプッシュしないでくださいrefs/for/*)。raw リポジトリ ( ) に直接プッシュする必要がありますrefs/heads/*。これは、Gerrit でレビューをバイパスする権限が必要になることを意味します。一時的にアクセス許可を付与し、これが完了したら削除することをお勧めします。これにより、将来誤ってレビューをバイパスしないようにすることができます。

履歴を書き換えるように git に指示するgit pushには、フラグを付けてを実行する必要もあります。-f

于 2013-06-27T14:07:30.980 に答える