(一)git修改已提交的user和email信息
Your name and email address were configured automatically based on your
username and hostname.Please check that they are accurate.
You can suppress this message by setting them explicitly:
$git config --global user.name "lufei"
$git config --global user.email lufei@example.com
If the identity used for this commit is wrong,you can fix it with:(补充:当提交代码时的use.name和email.name与gerrit
代码评审网页上的nema,email不匹配时需要修改提交用户名和email)
$ git commit --amend --author='lufei <lufei@example.com>'
(二)其他情况需要用到git commit --amend
不管是审核未通过,返回修改。还是有冲突,不能合入代码库,都是一样的解决方法。
如果代码审核未通过,现在本地git log查看一下。最近的一条log是不是就是你要修改的那一个,是的话,OK,不
是的话,git reset --soft commit_id到你需要修改的那一个commit记录。
继续修改你要改的文件
git add
git commit --amend
repo upload
三步,ok!注意如果你提交了3个文件,其中一个不过关,只需要修改、add 那一个文件就行。如果少提交了一个文件,也是add这个文件就ok了。
如果你多提交了一个文件,处理方法:
mv filename newfilename #先把文件重命名,此时git status查看,可以看到多余commit的文件处于工作区delete状态。
git commit -a --amend
然后git log --name-status -1 查看多余提交的文件已被撤销,此时可将之前重命名的文件再改回来重新upload后会生成一个patch set 2。