Git commit填写错误,如何修改? 1. 找到你误提交之前的版本号$ git log
2. 还原$ git revert -n 版本号
# -n, --no-commit don't automatically commit, 不加-n 进入vim编辑格式,编辑-m的信息 3. 提交$ git commit -m xxxx
第一种情况:刚刚commit
,还没有push
,需要修改commit
信息时: # 修改commit
信息$ git commit --amend
; 进入编辑页面后,修改要写错的commit
信息进行保存; 再次使用git log
查看,即可发现commit
信息发生了改变。 第二种情况:如果已经提交push
,则需要 1.git commit --amend
2.git push --force origin 远程分支名
ex)$ git push -f origin 远程分支名
4. 推送到远程git push 远程分支
OK,版本信息已经还原