git 撤销最后一次提交
I'm a massive fan of git; it's super powerful and easy to use, especially when it comes to branching. The biggest sin I commit when using git is adding files and then committing them...to master
branch instead of a feature branch. Oops. Certainly don't want that.
我是git的忠实粉丝; 它超级强大且易于使用,尤其是在分支方面。 使用git时,我犯下的最大罪过是添加文件,然后将它们提交到master
分支而不是feature分支。 哎呀。 当然不想要。
If you've done a git add (files)
and then commit them to the wrong branch, backing that out is easy:
如果您已经执行了git add (files)
,然后将它们提交到错误的分支,则备份起来很容易:
git reset --soft HEAD~1
With the command above, the files are still added but not committed, so you can create your feature branch, do another git commit -m (message)
, and be on your way!
使用上面的命令,文件仍会添加但尚未提交,因此您可以创建功能分支,再执行git commit -m (message)
,然后就可以了!
git 撤销最后一次提交