git commit --amend修补提交用法总结

(一)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。

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值