git diff显示不够 [英] git diff doesn't show enough

查看:804
本文介绍了git diff显示不够的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看看主分支和我的功能分支之间的区别。我有很多从主人拉到我的功能分支,并希望看到如果我将我的功能合并到主人将被添加的更改。



这是我的情况:

   -  *  -  *  -  * ----- *< master> 
\\\
1 - * - * - * - 2 - *< feature>

我的问题是 git diff主要功能似乎只显示提交编号2.我想看到github拉请求会显示的差异,我相信这是所有提交的方式1.
我注意到 git cherry

感谢您的任何建议。

解决方案 git diff AB 的重要意义在于,它只能向您显示树之间的确切状态之间的差异提交图中的两点 - 它不关心历史。用于 git diff .. ... >具有以下含义:





所以当你运行 git diff master feature 时,您所标记为 2 的提交引入的更改 - 输出应显示 master 中提交的树的状态之间的确切区别。 code>以及树的状态在特性中提交。如果它没有向您显示功能分支上的早期更改,那么您可能已经解决了来自以前版本的合并中的冲突,以支持 master

$ b中的版本
$ b

由于,它讨论了。


I want to see the difference between the master branch and my feature branch. I have many pulls from the master to my feature branch and want to see the changes that would be added if I merged my feature into the master.

This is my situation:

-*--*--*-----*<master>
  \     \     \
   1--*--*--*--2--*<feature>

My problem is the git diff master feature seems to only display commit number 2. I want to see the diff that a github pull request would show, which I believe is all the way to commit 1. I noticed git cherry shows me the commits I want to see the difference for.

Thanks for any advice.

解决方案

The important thing to realize about git diff A B is that it only ever shows you the difference between the states of the tree between exactly two points in the commit graph - it doesn't care about the history. The .. and ... notations used for git diff have the following meanings:

So when you run git diff master feature that's not just showing you the change introduced by the commit you've marked as 2 - the output should show the exact differences between the state of the tree commited in master and the state of the tree commited in feature. If it's not showing you the earlier changes on your feature branch, perhaps you resolved conflicts from the earlier merges from master in favour of the version in master?

As cebewee says it may be that what you want is git log -p master..feature, since git log does care about history. The meaning of .. and ... for git log are different since they select a range of commits:

Incidentally, its often said that merging from master into a topic branch is the wrong thing to do - instead you should be rebasing, or merging your topic branch into master after it is complete. This keeps the meaning of the topic branch easily understood. The git maintainer did a (somewhat difficult to understand) blog post about the philosophy of merging which discusses that.

这篇关于git diff显示不够的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆