How to undo the last commit
This question already has an answer here:
Disclaimer: don't do this if you pushed already and someone else may have pulled.
If you just want to add files to that commit:
git add <files>
git commit --amend --no-edit
Otherwise you can undo and redo the commit completely, as detailed here: How to undo last commit(s) in Git?
You can undo last commit by:
git reset --soft HEAD~
In case you have a typo in commit message and just want to edit the message, you can do:
git commit --amend
In case you made a commit but one of the file has an error. You can make a change and then simply update the commit.
git add <file_path>
git commit --amend
If down the history you have made a mistake with commit message, you can do:
git rebase-reword <commit-id>
Be very careful when you are editing the history. If you have pushed this change to the origin, this can cause problems with other contributors.
链接地址: http://www.djcxy.com/p/588.html上一篇: 是否可以将CSS应用于角色的一半?
下一篇: 如何撤消上次提交