Sometimes I have the following problem:
Add some commits in a feature branch.
Update master from upstream.
Want to see the diff between the feature branch and master, but git diff master
shows all of the things that have been added/removed in master, when I really only want to see the commits that the feature branch is ahead of master, not the ones that it's behind.
Is there a way to do this without having to merge master into the feature branch?
In order to see the commit differences between two branches, use the “git log” command and specify the branches that you want to compare. Note that this command won't show you the actual file differences between the two branches but only the commits.
The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.
"git diff" always show the difference between two commits (or commit and working directory, etc.).
Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.
I think the right answer is triple dot
git diff master...feature
That shows only new changes on feature with respect to master. See also: git diff - show only what's new on the remote
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With