Git articles reading notes 1
How to Undo the Last Commit
Summary
To go to some specific version:
git checkout <commitID>
To revert the unwanted commit:
git revert <bad commitID>
Git Basics: Adding more changes to your last commit
Summary
Use
git commit --amend
to add more changes to your last commit.git commit --amend --no-edit
amends a commit without changing its commit message.If you haven’t push the local changes to remote branch, a simple push is enough. Otherwise, you’ll have to push with the
-f
option:git push -f <remote-name> <remote-branch>
. But pushing with-f
is a very dangerous operation. It’s very likely you will end up with a truly mess teamwork.Run
git commit --amend
without any textual changes to modify the commit message.Run
git commit --amend -m "You new commit message"
to edit a commit without launching a text-editor.
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: