花美男为中国互联网事业而奋斗

修改git commit

来源:未知 阅读(0)次 评论(0)

当你不小心,写错了提交的注释信息,该如何处理呢。

在Git中,其commit提供了一个--amend参数,可以修改最后一次提交的信息.但是如果你已经push过了,那么其历史最后一次,永远也不能修改了。

git add -A .
git commit --amend

然后在出来的编辑界面,直接编辑 注释的信息

Selection_021.png

save, then you can see ...

Selection_022.png

Amending the most recent commit message

git commit --amend

Will open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line with:

git commit --amend -m "New commit message"

…however, this can make multi-line commit messages or small corrections more cumbersome to enter.

Make sure you don't have any working copy changes staged before doing this or they will get committed too. (Unstaged changes will not get committed.)



More :http://stackoverflow.com/questions/179123/how-to-modify-existing-unpushed-commits

标签:gitcommit--amend
上一篇:Git reflog机制 下一篇:Git 工作流程

相关推荐