当 head 处于特定提交时,我想获取一个 diff 文件,以便我可以将 head 降低一个级别,然后在应用和不应用 diff 文件的情况下尝试测试功能。那么有没有一种方法可以生成特定提交的差异文件。
尽管有一种方法可以在提交前后更改头部,但这种方法更加方便。
最佳答案
查看特定提交的更改:
git diff <commit-sha> -p
或者,
git show --decorate <commit-sha> # See 'Author', 'Date' and 'diff'
查看两个提交的差异:
git diff <commit1> <commit2>
查看特定提交的文件
更改:
git show <commit>:<file>
查看一段时间内的所有更改(例如,1 天):
git whatchanged --since="1 day ago" -p
git whatchanged --since="1 day ago" -p <file> # See changes for a specific file only
关于git - 在 Git 中生成特定提交的差异文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42357521/