一、通過git diff 命令生成patch文件
1.還未提交的修改
git diff > commit.patch
2.已提交的修改
git diff 3da71ca35 8b5100cdcd > commit.patch
注)3da71ca35 在8b5100cdcd 前面
如果是只想回退一個commit,可以git diff 3da71ca35^ 3da71ca35 > commit.patch
3.已經add但是未commit的修改
git diff --cached > commit.patch
4.檢查patch是否可以應用
git apply --check commit.patch
5.打補丁
git apply commit.patch