git 提交的撤销和恢复

查看某次提交旧版本里的内容

  • git show <commit-id>:path/to/file

从之前的某次提交中恢复某个文件

  • git restore --source <commit-id> -- path/to/file
  • git checkout <commit-id> -- path/to/file

撤销上次提交里的某个文件的修改

  • git restore --source=HEAD~1 --path/to/file

撤销很久之前某次提交对某个文件的修改

  • git diff <commit-id>^ <commit-id> -- path/to/file | git apply -R
posted @ 2026-04-10 23:04  箫笛  阅读(4)  评论(0)    收藏  举报