git - 比较 Git 对当前文件的提交更改

标签 git

如何通过 Git-show 显示文件最近 5 次提交与当前未提交文件的差异?

我更改了我的文件,这破坏了我的代码。但是,我不知道变化在哪里。

我想将当前未提交的文件与最近的提交 (HEAD)、之前的提交 (^HEAD) 以及至少 3 个更深的提交进行比较。

但是,我不知道如何才能有效地做到这一点。

在试图查看一个文件的最后五次提交对给定分支中当前文件的更改时,我没有成功运行

git show next~5:handle_questions.php

最佳答案

这是我的备忘单:

# uncommited file to HEAD
git diff <path>

# uncommited file to before last commit
git diff HEAD^ -- <path>

#last commit to before last commit
git diff HEAD^ HEAD -- <path>

#difference between HEAD and n-th grandparent
git diff HEAD~n HEAD -- <path>

#Another cool feature is whatchanged command
git whatchanged -- <path>

关于git - 比较 Git 对当前文件的提交更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1303315/

相关文章:

git - Bash 脚本协助查找

git 流分支有分歧

git - MAC + git gui->软件包 "Tcl": have 8. 5.9版本冲突,需要8.6

git - 如何检测强制更新

git - 设置好Gitosis,但是无法clone

git - 无需 checkout 即可下载 Git LFS 文件

git - 如何将更改提交到另一个预先存在的分支

git - 如何重置所有已删除的文件

linux - 没有管理员权限的服务器中组的 Git 存储库

windows - 如何更改git目录分隔符?