git status git log --oneline
# 修改最新提交(会打开编辑器修改提交信息) git commit --amend # 或者不改提交信息直接合并 git commit --amend --no-edit # 或者修改作者信息 git commit --amend --author="正确用户名 <正确邮箱>"
# 交互式重写提交历史 git rebase -i HEAD~n # n是要修改的提交数量 # 在编辑器中,将需要修改的提交前的"pick"改为"edit" # 然后对每个标记为edit的提交: git commit --amend --author="正确用户名 <正确邮箱>" --no-edit git rebase --continue
# 推送到master分支评审 git push origin HEAD:refs/for/master # 推送到特定分支评审 git push origin HEAD:refs/for/分支名
访问 Gerrit 链接查看评审状态:
http://101.43.95.130:8082/c/zhini_im/+/7
确保 Git 配置正确:
git config --global user.email "你在Gerrit注册的邮箱" git config --global user.name "你的Gerrit用户名"
如果推送失败,检查邮箱是否匹配:
# 查看当前提交的作者信息 git log --pretty=format:"%an <%ae>" -1
更新已推送到 Gerrit 的提交:
# 修改提交后强制推送更新 git commit --amend git push origin HEAD:refs/for/master # Gerrit 会自动识别为同一个变更的更新
查看远程仓库配置:
git remote -v
git commit --amend
恭喜你成功将代码推送到 Gerrit!
Deleting the wiki page "git修改合并提交" cannot be undone. Continue?