简体   繁体   English

如何在git分支上查看更改的文件

[英]How to view changed files on git branch

When reviewing someone's code in a topic branch, I want to quickly see the work done by the developer: a diff of what was changed on the branch against its forked commit, but without checking out the branch or comparing to my current branch, which may be another work-in-progress topic branch or whatever. 当在主题分支检讨别人的代码,我想很快看到由开发人员所做的工作:一diff什么是对针对其分叉分支改变承诺,但没有检出的分支或比较,以我目前的分支,它可能成为另一个进行中的主题分支或其他。

What I usually do is fetch the topic branch, then: 我通常要做的是获取主题分支,然后:

1) a git log ( git log --decorate --all --oneline --graph ) and pick the first and last commits on the branch, like: 1)一个git log( git log --decorate --all --oneline --graph )并选择分支上的第一个和最后一个提交,例如:

|  * 88aa417 (mybranch) the last commit in the topic branch
|  * ef16947 xxxxxxxxxxxxxxx
|  * b65ed5f xxxxxxxxxxxxxxxxx
|  * ce67c59 the first commit in the topic branch
| /
|/
* 008483e xxxxxxxxxxxxxxxxx

2) review the diff git diff mybranch..ce67c59~1 page by page, which nicely lists the changes the developer has made over his fork base. 2)逐页查看diff git diff mybranch..ce67c59~1 ,它很好地列出了开发人员对其前叉基础所做的更改。

Is there a git command that can do step 1 and 2? 是否有可以执行步骤1和2的git命令?

You're after git merge-base . 您正在使用git merge-base

git diff `git merge-base topic master`..topic

(edit: git has shorthand for this : (编辑: git对此有简写

git diff master...topic

to show the accumulated changes on topic since its history diverged from master, and 展示自从主题发展史以来与主题相关的累积变化,以及

git diff topic...master

to show the differences on the other side of the branch.) 以显示分支另一侧的差异。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM