如何让git diff只显示两次提交之间的差异,而不包括中间的其他提交?
当前回答
我的别名设置在~/。git的Bashrc文件:
alias gdca='git diff --cached' # diff between your staged file and the last commit
alias gdcc='git diff HEAD{,^}' # diff between your latest two commits
其他回答
我的别名设置在~/。ZSHRC文件git diff:
alias gdf='git diff HEAD{'^',}' # diff between your recent tow commits
谢谢 @Jinmiao罗
git差别头~2头
在最近的第二次提交和当前之间完成更改。
HEAD方便
从Git 2.19开始,你可以简单地使用:
Git range-diff rev1 -比较两个提交树,从它们的共同祖先开始
或 Git range-diff rev1~..rev1 rev2 ~ . . rev2 -比较2个提交所带来的变化
你可以简单地将2个提交传递给git diff,就像这样:
-> git diff 0da94be 59ff30c > my.patch
-> git apply my.patch
我的别名设置在~/。git的Bashrc文件:
alias gdca='git diff --cached' # diff between your staged file and the last commit
alias gdcc='git diff HEAD{,^}' # diff between your latest two commits
那么这个呢:
git diff abcdef 123456 | less
如果你想要在运行中比较许多不同的差异,将它管道到less是很方便的。
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别