如何让git diff只显示两次提交之间的差异,而不包括中间的其他提交?
当前回答
我的别名设置在~/。ZSHRC文件git diff:
alias gdf='git diff HEAD{'^',}' # diff between your recent tow commits
谢谢 @Jinmiao罗
git差别头~2头
在最近的第二次提交和当前之间完成更改。
HEAD方便
其他回答
假设你有这个
A
|
B A0
| |
C D
\ /
|
...
你要确保A等于A0。
这样就可以了:
$ git diff B A > B-A.diff
$ git diff D A0 > D-A0.diff
$ diff B-A.diff D-A0.diff
假设您想查看提交012345和abcdef之间的差异。以下内容可以达到你的目的:
$ git checkout 012345 $ git cherry-pick -n abcdef $ git diff --cached
直接在GitHub上查看差异;您可以- https://github.com/<username>/<reponame>/compare/<commit1>..<commit2> .
commit1和commit2可以是分支名或commit哈希值
为例:
比较gs/add-explicit-paths-to-js-files分支和gs/add-history-helper - https://github.com/twbs/bootstrap/compare/gs/add-explicit-paths-to-js-files..gs/add-history-helper 比较commit 75e09b1c0f5ae5f51078c7a25fe36d892c5cfcfe和585146a6a7aa70faf25442d7d28636ce57e29588 - https://github.com/twbs/bootstrap/compare/75e09b1c0f5ae5f51078c7a25fe36d892c5cfcfe..585146a6a7aa70faf25442d7d28636ce57e29588
在比较提交中阅读更多信息
我的别名设置在~/。ZSHRC文件git diff:
alias gdf='git diff HEAD{'^',}' # diff between your recent tow commits
谢谢 @Jinmiao罗
git差别头~2头
在最近的第二次提交和当前之间完成更改。
HEAD方便
我的别名设置在~/。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告诉我“没有这样的远程‘原点’”?
- 如何从远程分支中挑选?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?
- 错误:您对以下文件的本地更改将被签出覆盖
- Git rebase—即使所有合并冲突都已解决,仍然会继续报错
- 在Git中,我如何知道我的当前版本是什么?
- 跟踪所有远程git分支作为本地分支
- 自定义SSH端口上的Git
- git如何显示不存在于.gitignore中的未跟踪文件
- Git错误:遇到7个文件应该是指针,但不是