Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不小心做了很多,我添加了更改并想做,git commit -m "foo"但我输入错误并输入了git commit -a -m "foo".
git commit -m "foo"
git commit -a -m "foo"
我怎样才能恢复它,而不会丢失我所做的更改?
使用git reset HEAD^. 这将摆脱当前分支中的最新提交,但保持工作树完好无损。
git reset HEAD^
请注意,这会重写历史。如果您已经发布了该提交并且人们拉了它,最好通过创建一个新提交来撤消git revert HEAD提交,从而撤消上次提交的更改。
git revert HEAD