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 协议》,转载必须注明作者和本文链接
日拱一卒
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
93
粉丝
85
喜欢
153
收藏
121
排名:71
访问:11.4 万
私信
所有博文
社区赞助商