简体   繁体   中英

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.

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:

|  * 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.

Is there a git command that can do step 1 and 2?

You're after git merge-base .

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

(edit: git has shorthand for this :

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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