最近使用gerrit作codereview,在本地进行了三次提交,最后想push到远程仓库,出现提交错误
you are not allowed to upload merges,后面查了说是grerrit一个bug,也不知道算不算bug,就是多次提交后再提交到gerrit作代码
review就会有问题。解决办法就是恢复到自己提交修改前版本,然后整体合并一次提交,步骤如下:
1、git log 查看之前版本hash值
2、git reset --soft 0b598e0b7db78d343d63a85eb9fe781a4335cd49 (注意要--soft参数不然本地修改的代码也没有了)
3、git pull --rebase
如果遇到如下错误
error: cannot pull with rebase: You have unstaged changes.
error: additionally, your index contains uncommitted changes.
error: please commit or stash them.
需要转移分支修改过代码,使用
git stash
git pull --rebase
git stash pop
后面步骤和正常提交流程一样,git add -> git commit -> git push