最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]git中如何丢弃本地的改动

Git crifan 2670浏览 0评论

折腾:

[未解决]删除git之前某次提交的历史

期间,想要删除git的rebase的那一系列的操作

恢复到和服务器一致的版本

git remove local changes

bash – Various ways to remove local Git changes – Stack Overflow

去试试:

<code>licrifandeMacBook-Pro:crifanLib crifan$ git reset --hard
HEAD is now at 01b597d Merge branch 'master' of https://github.com/crifan/crifanLib
licrifandeMacBook-Pro:crifanLib crifan$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean
licrifandeMacBook-Pro:crifanLib crifan$ 
</code>

即可:

丢弃所有的改动,恢复到最新版。

【总结】

本地的丢弃改动,直接用:

<code>git reset —hard
</code>

即可。

转载请注明:在路上 » [已解决]git中如何丢弃本地的改动

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.170 seconds, using 22.00MB memory