(一)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 [email protected]
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 <[email protected]>'
(二)其他情況需要用到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。